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

Error Accesing Rows and Cells on the Client Side

1 Answer 17 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Antonio
Top achievements
Rank 1
Antonio asked on 16 Feb 2017, 02:10 PM

I'm having trouble accessing rows and cells in the RadGrid hierarchy. An error is occurring in the line "var cell = MasterTable.getCellByColumnUniqueName (row," Pro ") // cell"

Please help me.

Error: Unhandled exception at line 1452, column 29 in http://localhost:58910/_CC/ControlModel/Graphics.aspx
0x800a01b6 - JavaScript runtime error: Object does not support property or method 'getCellByColumnUniqueName'

 

<script type="text/javascript">

            function LoadValues() {
                var grid = $find("<%= RadGrid1.ClientID %>");
                var masterTable = grid.get_masterTableView();

                // get all rows in the grid
                selectedRows = masterTable.get_dataItems();

                for (var i = 0; i < selectedRows.length; i++) {
                    var row = selectedRows[i]; // found the row

                    for (var j = 0; j < row.get_nestedViews().length; j++) {
                        var detTable = row.get_nestedViews()[j]; // found the child table
                        var childRows = detTable.get_dataItems();

                        for (var k = 0; k < childRows.length; k++) {
                            var cRow = childRows[k];
                            var cell = cRow.getCellByColumnUniqueName(row, "ValueScore") 
                            var cellValue = cell.innerHTML;
                        }
                    }
                }
            }

 

 

               <telerik:RadGrid RenderMode="Lightweight" ID="RadGrid1" runat="server" ShowStatusBar="true" Skin="Windows7" AllowPaging="True" Width="900px" 
                    OnColumnCreated="RadGrid1_ColumnCreated" OnItemDataBound="RadGrid1_ItemDataBound" OnPreRender="RadGrid1_PreRender" 
                    OnNeedDataSource="RadGrid1_NeedDataSource" AllowMultiRowSelection="true" OnDetailTableDataBind="RadGrid1_DetailTableDataBind">
                    <GroupingSettings CollapseAllTooltip="Collapse all groups" />
                    <ClientSettings AllowColumnsReorder="true">
                        <Selecting AllowRowSelect="true" />
                    </ClientSettings>
                    <MasterTableView DataKeyNames="CodigoRede" ClientDataKeyNames="CodigoRede" Name="Rede">
                        <DetailTables>
                            <telerik:GridTableView DataKeyNames="CodigoSubRede" ClientDataKeyNames="CodigoSubRede" Name="SubRede" Width="868px" ShowHeader="true" ShowFooter="false">
                                <Columns>
                                    <telerik:GridClientSelectColumn UniqueName="SelectColumnNameSubRede"></telerik:GridClientSelectColumn>
                                    <telerik:GridBoundColumn DataField="ValorScoreSubRede" UniqueName="ValueScore" HeaderText="Value Score" HeaderButtonType="TextButton" Visible="true">
                                        <ItemStyle Width="316px" HorizontalAlign="Left" />
                                    </telerik:GridBoundColumn>
                                </Columns>
                            </telerik:GridTableView>
                        </DetailTables> 
                        <RowIndicatorColumn Visible="false"></RowIndicatorColumn>
                        <Columns>
                            <telerik:GridClientSelectColumn UniqueName="SelectColumnName"></telerik:GridClientSelectColumn>
                            <telerik:GridTemplateColumn HeaderText="Ideal Score">
                                <ItemStyle HorizontalAlign="Right" Width="330px" />
                                <ItemTemplate>
                                    <telerik:RadSlider ID="RadSliderValorScoreMinMax" runat="server" Orientation="Horizontal" MinimumValue="0" MaximumValue="99" SmallChange="1" LargeChange="10" 
                                        ItemType="Tick" Width="300px" Height="70px" ShowDecreaseHandle="true" ShowIncreaseHandle="true" EnableDragRange="true" EnableServerSideRendering="true" 
                                        IsSelectionRangeEnabled="true" AutoPostBack="false" Skin="Windows7" OnClientValueChanged="OnClientValueChanged" DataValueField="">
                                    </telerik:RadSlider>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                        </Columns>
                    </MasterTableView>
                </telerik:RadGrid>
                <br />
                <asp:Button ID="buttonClick" runat="server" Text="buttonClick" OnClientClick="buttonClick(); return false;" />

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 21 Feb 2017, 07:59 AM
Hi Antonio,

You can check the approach demonstrated in the following section for traversing the detail tables:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/hierarchical-grid-types-and-load-modes/traversing-detail-tables#looping-through-the-detail-tablesitems-in-telerik-radgrid-on-the-client

Also, you can experiment by changing the load mode of the hierarchy:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/hierarchical-grid-types-and-load-modes/hierarchy-load-modes

Please place a debugger before the problematic line and ensure that the Telerik GridDataItem object is properly referenced and loaded. Once you have the item object, you can use one of the following methods to get the value:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/rows/accessing-cells-and-rows#accessing-cells-and-values-in-client-side-code

You can also examine the implementation demonstrated in the attached web site sample.

I hope this will prove helpful.

Regards,
Eyup
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Antonio
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or