Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
115
iggrid knockout extension should expose an observable array of selected rows
posted

Hi,

It would be nice if the iggrid extension exposes an observable array of selected rows (items).

We've started to create an implementation to do this, although it would be better if it could be included in the standard iggrid-knockout-extension.

ko.bindingHandlers.igGridSelection = {
        init: function (element, valueAccessor, allBindingsAccessor, viewModel) {
            var selectedRowsArray = valueAccessor(); // By ref ?
            var dataSource = allBindingsAccessor().igGrid.dataSource;
 
            $(element).bind('iggridselectionrowselectionchanged',
                                 function (evt, ui) {
                                     selectedRowsArray.removeAll();
                                     var rows = ui.selectedRows;
                                     for (var i = 0; i < rows.length; i++) {
                                         var index = rows[i].index;
                                         selectedRowsArray.push(dataSource()[index]);
                                     }
                                 });
 
            $(element).bind('iggridsortingcolumnsorting',
                                function (evt, ui) {
                                    selectedRowsArray.removeAll();
                                });
 
        }
    };

Currently the 'iggridselectionrowselectionchanged' event is only raised when adding rows to the selected rows list.
We've opened a discussion on this forum to have the event also raised when deselecting,
this would make it much easier to implement the selected rows in the knockout extension.
Greetings,
Christophe
Parents
No Data
Reply
  • 1015
    posted

    Have you guys figured the bindings out for a KO observable of selected rows?  The code would be really helpful to me right now.  Thanks.

Children
No Data