jQWidgets Forums

jQuery UI Widgets Forums Grid get (and update) row by ID which is a column

This topic contains 2 replies, has 2 voices, and was last updated by  elessar 10 years, 7 months ago.

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

  • elessar
    Participant

    I have following grid structure

     $("#statisticsGrid").jqxGrid({
            height: 200,
            width:'99%',
            columns: [
                { text: 'ID', datafield: 'personID', width: '10%' }, //this ID is unique
                { text: 'Person', datafield: 'personName', width: '20%' },
                { text: 'Distance Passed', datafield: 'distance', width: '23%' },
                { text: 'Avg speed', datafield: 'avg', width: '23%' },
                { text: 'Max Speed', datafield: 'max', width: '23%' }
            ]
        });

    everything’s fine, grid is created and I create rows for some number of persons. Now after some while I receive new data for a person with ID 123456. I process this data and now I want to modify corresponding row for this person with ID 123456.
    Question is, how can I get this row?

    Of course I can get all rows and iterate through them until I find the right row, but I think, that this might be slower with large number of rows.


    Dimitar
    Participant

    Hello elessar,

    In your grid source definition you would have to set the id property to the “personID” datafield (column). This way, your rows will have an actual id equal to their “personID” cell and you can then use methods such as getrowdatabyid, getcellvaluebyid and setcellvaluebyid. I.e.:

    var source =
    {
        datatype: "json",
        datafields: [
            { name: 'personID' },
            { name: 'personName' },
            { name: 'distance' },
            { name: 'avg' },
            { name: 'max' }
        ],
        id: 'personID',
        url: 'source.txt'
    };

    Best Regards,
    Dimitar

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


    elessar
    Participant

    thanks, works like a charm

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

You must be logged in to reply to this topic.