Loop through displayed rows

2 posts, 0 answers
  1. Johnathan
    Johnathan avatar
    31 posts
    Member since:
    Sep 2012

    Posted 01 Nov Link to this post

    Hello,

    Is there a way to loop through only the displayed rows of a radgrid, preferably on the client-side with javascript?

    Thanks,

    Johnathan

  2. Patrick
    Admin
    Patrick avatar
    173 posts

    Posted 02 Nov Link to this post

    Hello Johnathan,

    One way is get a reference to the masterTableView, get the dataItems, and loop through each item.    In this case, I'm getting the cell under ProductName and the element.

    Here is the JavaScript:
    function Click() {
        var grid = $find("<%=RadGrid1.ClientID %>");
        var masterTable = grid.get_masterTableView()
        var dataItems = masterTable.get_dataItems();
        for (var i = 0; i < dataItems.length; i++) {
            console.log(dataItems[i].get_cell("ProductName").innerHTML);
            console.log(dataItems[i].get_element());
        }
    }

    I've attached a project which illustrates this approach.

    Hope this helps!

    Regards,
    Patrick
    Telerik by Progress
    Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top