This is a migrated thread and some comments may be shown as answers.

[Solved] How to get radgrid row data(all rows) using javascript?

1 Answer 735 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vaibhav
Top achievements
Rank 1
Vaibhav asked on 17 Apr 2008, 11:33 AM
Hi,

The grid sample is:

<rad:RadGrid ID="dgrdjob" EnableAJAXLoadingTemplate="true" LoadingTemplateTransparency="40"
    MasterTableView-CellPadding="0" runat="server" AllowPaging="True" AllowSorting="True"
    CellSpacing="0" CellPadding="0" BorderStyle="None" PageSize="20" HorizontalAlign="left"
    FilterItemStyle-BackColor="#FFE88C" AllowFilteringByColumn="FALSE" Width="100%"
    Height="100%" AutoGenerateColumns="False" Skin="dgrdStyle" OnItemEvent="dgrdjob_ItemEvent"
    EnableAJAX="True" FilterMenu-TextColumnBackColor="Window" FilterMenu-SelectColumnBackColor="#FFE88C"
    PagerStyle-ShowPagerText="true" PagerStyle-PagerTextFormat="<br>Change page: {4} &nbsp;|&nbsp; Displaying page {0} of {1}, items {2} to {3} of {5}.">
    <HeaderStyle HorizontalAlign="left" VerticalAlign="Middle" Font-Bold="true" Font-Names="verdana"
    Font-Size="8.5pt" Height="25px" ForeColor="Black" CssClass="bgtop"></HeaderStyle>
    <PagerStyle CssClass="dgrdpager" Font-Bold="false" AlwaysVisible="true" Mode="NextPrevNumericAndAdvanced">
    </PagerStyle>
    <AlternatingItemStyle CssClass="bgleft" />
    <FilterMenu HoverBackColor="#FFE88C" HoverBorderColor="#FFE88C"></FilterMenu>
    <MasterTableView NoMasterRecordsText="No records found." RowIndicatorColumn-Display="false"
    CellPadding="1">
    <Columns>
        <rad:GridTemplateColumn HeaderText="Edit" Reorderable="False" Resizable="False" AllowFiltering="False"
        UniqueName="TemplateColumn" ItemStyle-Font-Names="Verdana" ItemStyle-VerticalAlign="NotSet">
        <ItemStyle CssClass="lnkcolor" />
        <ItemTemplate>
            <asp:LinkButton ID="lnkBroadcastID" ToolTip="" runat="server" CommandName="Summary">LinkButton</asp:LinkButton>
        </ItemTemplate>
        </rad:GridTemplateColumn>
        
        <rad:GridTemplateColumn DataField="Description" AllowFiltering="true" HeaderText="Description"
        Reorderable="False" UniqueName="description" ItemStyle-Font-Names="Verdana" SortExpression="Description"
        Resizable="False">
        <ItemTemplate>
            <asp:Label ID="lblDescription" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.description") %>'>
            </asp:Label>
        </ItemTemplate>
        </rad:GridTemplateColumn>
        
        <rad:GridTemplateColumn DataField="status" HeaderText="Status" Resizable="False"
        Reorderable="False" UniqueName="Status" ItemStyle-Font-Names="Verdana" AllowFiltering="true">
        <ItemTemplate>
            <asp:Label ID="lblStatus" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.status") %>'>
            </asp:Label>
           </ItemTemplate>
        </rad:GridTemplateColumn>
        
    </Columns>
    
    <ExpandCollapseColumn Visible="False">
        <HeaderStyle Width="19px" />
    </ExpandCollapseColumn>
    <RowIndicatorColumn>
        <HeaderStyle Width="20px" />
    </RowIndicatorColumn>
    </MasterTableView>
    <ClientSettings ReorderColumnsOnClient="False" AllowDragToGroup="False" AllowColumnsReorder="False">
    <Resizing AllowRowResize="false" AllowColumnResize="false"></Resizing>
    </ClientSettings>
    <FilterItemStyle BackColor="" BorderColor="Black" Width="20px" Wrap="True" />
</rad:RadGrid>

The grid has following columns
1) Edit - job_id
2) Description - Description
3) status - status

Using javascript I want to pick job_ids as comma separated string for the rows where status = "NEW"
job_id in LinkButton, status in label.

javascript code I am trying is:

....
....
tagName = "*"; //* means all elements
var grid = document.getElementById("<%=dgrdjob.ClientID %>");
var elements = grid.getElementsByTagName(tagName);

for (var i = 0; i < elements.length; i++)
{
    var element = elements[i];
    alert(element.id);
}
....
....


I am unable to get expected element id.

1 Answer, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 17 Apr 2008, 12:10 PM
Hello Vaibhav,

To see more information on the requested functionality, please refer to the following help article. Of specific interest is the get_dataItems() property, giving you access to all the rows in the control.
I hope this suggestion helps.

Best wishes,
Yavor
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
Vaibhav
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Share this question
or