jQWidgets Forums

jQuery UI Widgets Forums Grid Fetching primary column data when secondary columns are edited

This topic contains 9 replies, has 2 voices, and was last updated by  Ansh 12 years, 12 months ago.

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

  • Ansh
    Member

    Hi,

    I am quite new to Jqwidgets , and i found the implementation of Jqwidgets powerful and i have started using it.

    I tried to populate the grid with data as rows , which is built dynamically and mapped to the grid and below is the sample data.

    [
    {
    “Applies”:”Grtx”,
    “id”:”27255.43719″,
    “name”:”Grtx/56310″,
    “Node”:”1″,
    “Note”:”Dan on SOS check”,
    “Priority”:”High”
    },

    {
    “Applies”:”Oss”,
    “id”:”27255.43720″,
    “name”:”Oss/46310″,
    “Node”:”8″,
    “Note”:”Check the variant”,
    “Priority”:”Meduim”
    }

    {
    “Applies”:”Mss”,
    “id”:”27255.43439″,
    “name”:”Mss/231310″,
    “Node”:”9″,
    “Note”:”No Check”,
    “Priority”:”Low”
    }

    ]

    From the above data, keys are shown as rows header with name (pinned column header),applies,node,note,priority as column headers and id is never shown used as primary column.
    And the values are took as row data under each header.

    Issue:
    when the data is modifed in each row i am able to get the data modifed with ‘cellbegineditevent’ and ‘cellendeditevent’ based on row id ,

    But i want to get the ‘id’ data which is hidden based on the changes done in each cell of the row through respective rowid .

    Kindly help me on this issue as i am really struck.

    Thanks
    Ansh


    Peter Stoev
    Keymaster

    Hi Ansh,

    Have you tried using the jqxGrid’s getrowdata method to get a row at specific index? In addition, the source object’s updaterow is called when a cell value is changed and the edited row is passed as parameter.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    Ansh
    Member

    Hi Peter,

    Thanks for the quick response.

    With the data as mentioned previously assigned to grid i.e as below

    [
    {
    “Applies”:”Grtx”,
    “id”:”27255.43719″,
    “name”:”Grtx/56310″,
    “Node”:”1″,
    “Note”:”Dan on SOS check”,
    “Priority”:”High”
    },

    {
    “Applies”:”Oss”,
    “id”:”27255.43720″,
    “name”:”Oss/46310″,
    “Node”:”8″,
    “Note”:”Check the variant”,
    “Priority”:”Meduim”
    }

    {
    “Applies”:”Mss”,
    “id”:”27255.43439″,
    “name”:”Mss/231310″,
    “Node”:”9″,
    “Note”:”No Check”,
    “Priority”:”Low”
    }

    ]

    Yes indeed i have tried the mentioned methods. But i still not able to read the data. Please find the code snippet

    var tempArray = new Array();
    $(“#jqxgrid1”).bind(cellendedit’, function (event) {
    var args = event.args;
    var column = args.datafield;
    var row = (args.rowindex);
    var value = args.value;

    // Approach1
    var data = $(‘#jqxgrid1’).jqxGrid(‘getrowdata’, args.rowindex);
    console.log(‘ data >>> ******** ‘ + data ); // Result is [object Object] ,
    Please suggest how to know what are changed values in the row for Approach1.

    // Approach2 , since approach1 result is not i was expecting , i have tried with an tempArray multiple times changing
    columns of different rows
    tempArray .push(data );
    console.log(‘ tempArray >>> ******** ‘ + tempArray );
    // Result is [object Object],[object Object],[object Object],
    Please suggest how to know what are changed values in the row for Approach2.

    });

    I guess i am not using the proper way for retrieval of changed columns of each row.

    Please help me on this issue to proceed further to get to solution.

    Regards
    Anshi


    Peter Stoev
    Keymaster

    Hi Anshi,

    – With Approach 1, in the cellendedit, you have the edited cell’s datafield and the row’s index. That’s the changed cell. The args.value in the event handler is the new value of the cell. The result of getrowdata is an Array of cell values. Ex: var cellValue1 = row[“id”], etc.
    – I don’t understand what you actually try to do in Approach 2.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    Ansh
    Member

    Hi Peter,

    With respect to approach1 i am getting the data, my concern is will the data be sent the same format as the data sample though with only changed data.

    With respect to approach2 i wish to store the changed row data from the grid in an array and send to server to update database.

    From both the approaches i only wish to send the changed data to database with primary column data i.e ID from the data sample to indentify the unique key of each row sent to server.

    Please let me know if my approach is correct. Your inputs value a lot.

    Thanks
    Anshi


    Peter Stoev
    Keymaster

    Hi Anshi,

    It depends on your implementation how the data will be send to the server. It comes from the Grid as an Array, but you decide how to format that array. See this help topic: php-server-side-grid-crud.htm.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    Ansh
    Member

    Hi Peter,

    As i am working with Java , i would like to know if the changed data can be sent to server the same format as it was originally mapped to grid.

    Example:

    Original Data:
    [
    {
    “Applies”:”Grtx”,
    “id”:”27255.43719″,
    “name”:”Grtx/56310″,
    “Node”:”1″,
    “Note”:”Dan on SOS check”,
    “Priority”:”High”
    },

    {
    “Applies”:”Oss”,
    “id”:”27255.43720″,
    “name”:”Oss/46310″,
    “Node”:”8″,
    “Note”:”Check the variant”,
    “Priority”:”Meduim”
    }

    {
    “Applies”:”Mss”,
    “id”:”27255.43439″,
    “name”:”Mss/231310″,
    “Node”:”9″,
    “Note”:”No Check”,
    “Priority”:”Low”
    }

    ]

    Changed Rows Data:
    [

    {
    “Applies”:”Oss”,
    “id”:”27255.43720″,
    “name”:”Oss/46310″,
    “Node”:”16″,
    “Note”:”Check the variant”,
    “Priority”:”High”
    }

    {
    “Applies”:”Mss”,
    “id”:”27255.43439″,
    “name”:”Mss/231310″,
    “Node”:”20″,
    “Note”:”No Check”,
    “Priority”:”Medium”
    }

    ]

    Could you please let me know how to achieve this format to be sent from the ‘cellendedit’ in updaterow method.

    Thanks and Regards
    Anshi


    Ansh
    Member

    Hi Peter,

    As i am working with Java , i would like to know if the changed data can be sent to server the same format as it was originally mapped to grid.

    Example:

    Original Data:
    [
    {
    “Applies”:”Grtx”,
    “id”:”27255.43719″,
    “name”:”Grtx/56310″,
    “Node”:”1″,
    “Note”:”Dan on SOS check”,
    “Priority”:”High”
    },

    {
    “Applies”:”Oss”,
    “id”:”27255.43720″,
    “name”:”Oss/46310″,
    “Node”:”8″,
    “Note”:”Check the variant”,
    “Priority”:”Meduim”
    }

    {
    “Applies”:”Mss”,
    “id”:”27255.43439″,
    “name”:”Mss/231310″,
    “Node”:”9″,
    “Note”:”No Check”,
    “Priority”:”Low”
    }

    ]

    Sorry about the previous post
    Changed Rows Data:
    [

    {
    “id”:”27255.43720″, –> Unique Key
    “Node”:”16″, –> Changed column1 –> ROW1
    “Priority”:”High” –> Changed column2
    }

    {

    “id”:”27255.43439″, –> Unique Key
    “Node”:”20″, –> Changed column1 –> ROW2
    “Priority”:”Medium” –> Changed column2
    }

    ]

    Could you please let me know how to achieve this format to be sent from the ‘cellendedit’ in updaterow method.

    Thanks and Regards
    Anshi


    Peter Stoev
    Keymaster

    Hi Anshi,

    You can use the jQuery’s map method to translate items from array into another collection. You can read about it here: http://api.jquery.com/jQuery.map/ or use the JSON stringify: https://github.com/douglascrockford/JSON-js/blob/master/json2.js

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    Ansh
    Member

    Hi Peter,

    Thanks very much. I would check with the links provided.

    Regards
    Anshi

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

You must be logged in to reply to this topic.