selection


programmatically change selected rows in a slickgrid


Using slickgrid, I need to select/deselect rows on the fly, and here is my code, it seems to work but sounds a bit suboptimal really, is there any smater means to do this ?
// turn records checkbox on or off depending on 'checked'
function set_checkbox (record, checked) {
var id = record[primary_key];
var index = dataview.getIdxById(id);
var selectedRows=this.slick_grid.getSelectedRows();
if (checked) // add index in current list
selectedRows=selectedRows.concat(index);
else // remove index from current list
selectedRows=selectedRows.filter(function(idx) {return idx!=index;});
this.slick_grid.setSelectedRows(selectedRows);
}
The grid is initialized with this selection model here:
grid.setSelectionModel (new Slick.RowSelectionModel ({selectActiveRow: false}));
This is quite simple using the grid helper method setSelectedRows(rowsArray)
The full description is here:
https://github.com/mleibman/SlickGrid/wiki/Handling-selection
Previous answer is correct if the rows are visible. However, programmatic selection typically means you have a different view of the same data and if the row containing selected item is hidden (due to filtering, group being collapsed, etc) then you really need to dig deeper and patch slickgrid to be able to select rows by Id. Hope this helps.

Related Links

Selecting who should breed with whom from a list of qualified parents?
programmatically change selected rows in a slickgrid
dgrid selection- select row only when I click on check box
Getting the Root-Element of an EObject which is being listened in a Tree-/Tableviewer
Rangy expands for cyrillic
Couldn't find box selection in Jdeveloper
In SAS, calculate value using conditional logic with different variables
Disable Text Selection in Chromium Embedded?
Retrieving Selection Data from Applications other than xterm
How to activate selected text replacement when typing new text?
GIMP: Subtract overlapping selections
Opencart: Add extra features under the same product
AQGridView Selection and Deselection
make 2 different selection-tools coexist in pyside
Swapping text selections in Sublime Text 2
Selecting text with Sublime Text 2

Categories

HOME
ionic2
magento2
automapper
adfs3.0
loopbackjs
web2py
cryptography
fogbugz
tfs2015
ontology
telegraf
lda
xades4j
rangy
django-rq
bnf
robolectric
http-authentication
unity-container
pst
kaggle
locks
delayed-job
rust-cargo
nest
directfb
cmis
love2d
android-n
python-sounddevice
netapp
jacoco-maven-plugin
1wire
type-inference
react-intl
destroy
.net-micro-framework
libreoffice-writer
comm
redisson
node-apn
solr-query-syntax
scala-collections
pen
nslayoutconstraint
mongodb-aggregation
nitrousio
annotatorjs
yargs
ogg
portal
okio
traversable
adp
uibinder
maximize
vaadin4spring
verisign
gridbaglayout
screen-orientation
componentart
createfile
juttle
comctl32
wicket-1.5
cout
coding-efficiency
jack
boolean-algebra
autonumber
mft
discovery
infinite
xsd2code
revmob
libxml-js
asp.net-mvc-3-areas
sfinae
image-scanner
jzmq
liveconnect
navigationcontroller
net-use
representation
winsxs
nsconnection
3des
anonymous-types
ios-4.2
cleartype
asdoc
firephp
data-retrieval
inversion
code-camp
bindable-linq
account-management

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App