Comments (12)
The method getSelected
is now included in core. Thanks guys!
from handsontable.
To select rows or columns index use selectCell
and specify the index. Example below to select the row/col 0,0
container.handsontable("selectCell", 0, 0);
The callback method described in Demo Page- Save
from handsontable.
Thank you for @azizasm !
I understand you are saying.
But I would like to know column and row index selecting now.
from handsontable.
This is how I've done it:
var selection = $("#exampleGrid").handsontable('getSelection');
selection is from col1,row1 to col2, row2
where
col1 = selection.start().col;
row1 = selection.start().row;
col2 = selection.end().col;
row2 = selection.end().row;
Hope that helps
from handsontable.
thanks @bruceh48 !
I tryed it but it occurred javaScript Error.
The details of Error: $(this).data("handsontable")[action] is undefined
Perhaps you could go into a little more detail.
from handsontable.
Oops my mistake..
I had forgotten that I had added an additional function to the handsontable.js file.
Its,
/**
* Returns the selection
*/
this.getSelection = function()
{
return selection;
};
I added it on line 2079, just after the function that starts with a line line that says :
this.selectCell = function
Without this, I could not "reliably" get the selection.
Its works well for me.
Hope that helps
from handsontable.
thanks @bruceh48 !
Mr. @warpech !
I'm glad you add above-mentioned @bruceh48 's code!
I beg your kindness.
from handsontable.
If you don't want to mess with the source code, all you really need is a little jQuery handler:
var rowIndex;
You could modify this just a bit to capture a row select from one of the arrow keys as well.
from handsontable.
Hi guys, I have created a callback called onSelection
. Use it as shown in http://warpech.github.com/jquery-handsontable/demo/conditional.html:
container.handsontable({
...
onSelection: function(row, col, row2, col2) {
var meta = container.handsontable('getCellMeta', row2, col2);
if(meta.isWritable == false) {
container.handsontable('updateSettings', {fillHandle: false});
}
else {
container.handsontable('updateSettings', {fillHandle: true});
}
},
...
}
Do you think @bruceh48 method still would be handy? I am thinking about including it in the core
from handsontable.
thanks @warpech !
I've found what I want to do.
from handsontable.
Yes, bruceh48's method would be very useful.
from handsontable.
The code added by @bruceh48 has unpredictable behaviour depending on which direction the user makes his selection. For example: if the user makes a selection from a,b to c,d, he gets the coordinates (a,b), (c,d). However, if the user selects from b,c to a,d (the exact same area), he gets different coordinates.
The following code fixes this error and is intended to replace the code given by @bruceh48
this.getSelected = function() {
var x1 = selection.start().row;
var y1 = selection.start().col;
var x2 = selection.end().row;
var y2 = selection.end().col;
if( (x1 <= x2 && y1 < y2) || (x1 < x2 && y1 <= y2) || (x1 == x2 && y1 == y2)) {
return [x1,y1,x2,y2];
}
else if( (x1 >= x2 && y1 > y2) || (x1 > x2 && y1 >= y2)) {
return [x2,y2,x1,y1];
}
else if(x1 < x2 && y1 > y2) {
return [x1,y2,x2,y1];
}
else if(x1 > x2 && y1 < y2) {
return [x2,y1,x1,y2];
}
};
The function $("#exampleGrid").handsontable('getSelected') now returns an array containing the coordinates, regardless of the direction of selection. [row1,col1,row2,col2]
I have have created a fork with this code in the appropriate place. See https://github.com/littley/jquery-handsontable
from handsontable.
Related Issues (20)
- [Bug]: "mergedHotSettings" Error reporting! HOT 5
- [Bug]: getCellsMeta return stale result if row and column have been inserted HOT 3
- Handsontable 14.2.0 is here!
- [Bug]: vue2, handsontable, use multi-column sort plug-in, start multi-column sort, beforeColumnSort execution time is what? HOT 1
- [Bug]: The setSortConfig setting is in effect, the page does not change, and the column size needs to be adjusted before it is displayed. HOT 4
- [Bug]: The 'core.spliceRow' method threw an exception HOT 3
- [Bug]: renderer function execution time? HOT 2
- [Bug]: In the demo code for Instance methods, hotInstance is not available when using typescript. HOT 2
- [Bug]: rowHeaders insert row above bug HOT 3
- [Bug]: React / Nested Rows / Nested row collapse status resets when props are passed from parent to child HOT 1
- [Bug]: When a specific row height is set and "wordWrap" is enabled, the row height can still change dynamically based on the content. HOT 2
- [Bug]: Missing cell borders HOT 1
- [Bug]: Installed 14.2 but having performance and display issue not seen with 13.0, also had to convert to ES5 HOT 16
- [Bug]: vue2 insert column disable? HOT 5
- How can i get the older version document, such as v6,v7? HOT 4
- [Bug]: Multiple sorting resets on the fifth click HOT 2
- [Bug]: custom rendorer called multiple times and did dom manipulation creating a slow performance and row misalignment HOT 1
- [Bug]: cell editor doesn't switch as intended on tab navigation between cells HOT 1
- [Bug]: Table crashes when entering a number value with a space between negative symbol and numbers HOT 1
- [Bug]: Vue 3 composition API ref error HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from handsontable.