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
2745
Updating all rows without databind
posted

I want to perform updates across the entire data set but without invoking a data bind.  The data bind causes the scrollbar to reposition itself back to the top of the data view which is causing user grief.  How do I update rows that aren't in the current data view?

//var data = $(".selector").data("igGrid").dataSource.dataView(); // Data for the current page
var data = $(".selector").data("igGrid").dataSource.data(); // Data for the entire local dataset

$.each(data, function () {
    // make changes to 'this'
    $(".selector").igGrid("updateRow", "primaryKey", this);
});

updateRow will fail if I try to update it this way.  I have to do this:

$.each(data, function () {
    // make changes to 'this'
    $(".selector").data("igGrid").dataSource.updateRow("primaryKey", this);
});
$(".selector").igGrid("dataBind");

Thoughts?

  • 5513
    Suggested Answer
    Offline posted

    Hello Daniel,

    You could check if the row you are trying to update is currently rendered and decide on the API function to use afterwards. The solution will look like this:

    var grid = $(".selector"), gridObj = grid.data("igGrid");
    $.each(data, function () {
        if (grid.find("tr[data-id='" + <primary key> + "']").length > 0) {
            grid.igGridUpdating("updateRow", <primary key>, this);
        } else {
            gridObj.dataSource.updateRow(<primary key>, this);
        }
    });

    I hope this helps! Thank you for using Infragistics forums!

    Best regards,

    Stamen Stoychev