jquery - JQGrid - Multiselect -


multiselect in jqgrid allows either multiple selection or single selections , shift functionality isn't i'd expect shift select do. don't need comboboxes multiselect.

what other solution use multiselect?

[oct 2011] updated use 4.0 api, corrected shift-selection bugs, simplified selection loop. tested in 4.2.0.


if me, needed proper multiselect in jqgrid - ctrl selects single row @ time, select selects multiple rows , neither clear selection , selects 1 row - you've found it.

first things first: set multiselect: true in grid definition (i didn't set other multiselect options)

next: in gridcomplete: function () {} set grid.jqgrid('hidecol', 'cb'); - hides checkboxes if don't want them.

finally: main part

beforeselectrow: function (rowid, e) {     if (!e.ctrlkey && !e.shiftkey) {         $("#grid").jqgrid('resetselection');     }     else if (e.shiftkey) {         var initialrowselect = $("#grid").jqgrid('getgridparam', 'selrow');         $("#grid").jqgrid('resetselection');          var currentselectindex = $("#grid").jqgrid('getind', rowid);         var initialselectindex = $("#grid").jqgrid('getind', initialrowselect);         var startid = "";         var endid = "";         if (currentselectindex > initialselectindex) {             startid = initialrowselect;             endid = rowid;         }         else {             startid = rowid;             endid = initialrowselect;         }          var shouldselectrow = false;         $.each($("#grid").getdataids(), function(_, id){             if ((shouldselectrow = id == startid || shouldselectrow)){               $("#grid").jqgrid('setselection', id, false);             }             return id != endid;                                 });     }     return true; } 

the end - hope helps


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -