jQuery UI Widgets Forums Grid jqxGrid with controller, how to implement best way

This topic contains 3 replies, has 2 voices, and was last updated by  Martin 5 years, 6 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author

  • copperfox
    Participant

    Hello dear friends!
    I use jqxgrid to make calculations like excel with the controller in the following way:

       $("#jqxGrid").on('cellvaluechanged', function (event) 
        {
            var rows = $("#jqxGrid").jqxGrid("getrows");   //1
            newrows = calculatejson(rows);    //3  
            redrawgrid(newrows);    //4
        });

    When user change some cell
    1. Get all rows
    3. Make all calculations and many other work.
    4. Push computed data back: Create new dataAdapter with data=jsongrid, call $(“#jqxGrid”).jqxGrid(source: dataAdapter);

    Maybe it is wrong way and there is good way to insert changed data back?


    Martin
    Participant

    Hello copperfox,

    You can also use the updatebounddata method of jqxGrid.
    To update only the data without the columns, use the ‘data’ parameter. To make a quick update of the cells, pass “cells” as parameter. Passing “cells” will refresh only the cells values when the new rows count is equal to the previous rows count. To make a full update, do not pass any parameter.

    Please, look at the following Example.

    Best Regards,
    Martin

    jQWidgets Team
    http://www.jqwidgets.com/


    copperfox
    Participant

    Thank you for answer. With this approach jqxgrid become a really powerful thing.
    Final code looks like:

    
    var rows = $("#jqxGrid").jqxGrid("getrows");
            jsongrid=rows;
            calculatejson(jsongrid);
            source.localdata = jsongrid;      
            $('#jqxGrid').jqxGrid('updatebounddata','cells');
    

    Tryed $('#jqxGrid').jqxGrid('updatebounddata','data'); – it works twice longer.

    But passing $('#jqxGrid').jqxGrid('updatebounddata') – make bad result. All grid colors and editables disappeared.

    Can you please tell what does it mean “update only data without columns” ? No columns params, colors updated?


    Martin
    Participant

    Hello copperfox,

    Yes, that is right. When you pass the ‘data’ param, only the data is updated.
    And if you don’t pass any parameter a full update is made.

    Best Regards,
    Martin

    jQWidgets Team
    http://www.jqwidgets.com/

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.