Question

I need to change all cells in the jqxgrid column when editing a single cell of that column. So, I loop through all cells on "cellvaluechanged" event:

var ri = -1;
$("#jqxGrid").on('cellvaluechanged', function (event) {
    if(ri != -1) return;
    var column = args.datafield;
    if(column == 'min'){
        var row = args.rowindex;
        if(ri == -1)ri = row;
            var griddata = $("#jqxGrid").jqxGrid('getdatainformation');
            var v = args.value;         
            for (var i = 0; i < griddata.rowscount; i++) {
                if(i != row){
                    $("#jqxGrid").jqxGrid('setcellvalue', i, 'min', v);
                }   
            }           
        ri = -1;            
    }
});

The problem is that it is too slow for large tables, because each change of cells in the loop calls "oncellvaluechanged" function again.

What is a more elegant way of doing this? I was thinking to unbind "oncellvaluechanged" before the loop and bind it back at the end, but am not sure how to do that.

Thanks

Was it helpful?

Solution

Instead of calling 'setcellvalue' for each cell you want to edit, it might be faster to edit the values directly in the dataAdapter. You can do that by accessing the 'records' parameter of dataAdapter.

Then, you will need to force your jqxGrid to refresh data. You can do this by calling 'render' or 'refresh'.

See those links for more infos :

http://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxdataadapter/jquery-data-adapter.htm

http://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxinput/jquery-input-api.htm

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top