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

JS error on getCellByColumnUniqueName

1 Answer 91 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Hk
Top achievements
Rank 2
Hk asked on 11 Jan 2009, 02:55 PM
I get this JS error when I call getCellByColumnUniqueName:
_242 is null 
getCellByColumnUniqueName()(null"iPackageId")ScriptRe...220000000 (line 3399) 
getDataItemKeyValue(Object, null)Default.aspx (line 235) 
RowSelected(Object, Object)Default.aspx (line 229) 
_handler()(Object, Object)ScriptRe...594496661 (line 2503) 
raiseEvent()("rowSelected", Object)ScriptRe...220000000 (line 794) 
(?)()()ScriptRe...220000000 (line 6551) 
_selectRowInternal()(tr#ctl00_ctl00_baseContentPlaceHolder1_cpContentArea_~/Configurations/RecordingConfiguration/TabControls/TabPackageSelection.ascxuserControl_RadGrid1_ctl00__1.GridAltRow_Vista, Object rawEvent=Event click altKey=false button=0, falsefalsetruetrue)ScriptRe...220000000 (line 2578) 
_click()(Object rawEvent=Event click altKey=false button=0)ScriptRe...220000000 (line 2485) 
(?)()()ScriptRe...594496661 (line 50) 
browserHandler()(click clientX=231, clientY=223)ScriptRe...594496661 (line 3034) 
[Break on this error] return _242.get_element().cells[i]; 

this is my page and grid:
<asp:Label runat="server" ID="RESX_lblChooseTelephonyEnviroment" meta:resourcekey="RESX_lblChooseTelephonyEnviroment"></asp:Label> 
<br /> 
<br /> 
<telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="PackagesDataSource" GridLines="None" 
    Skin="Vista" Width="100%" BorderWidth="0px" ShowHeader="False" AllowAutomaticDeletes="True" 
    AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowMultiRowEdit="false" 
    AllowMultiRowSelection="false"
    <HeaderContextMenu EnableTheming="True"
        <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
    </HeaderContextMenu> 
    <MasterTableView AutoGenerateColumns="False" CommandItemDisplay="TopAndBottom" DataKeyNames="iPackageId" 
        DataSourceID="PackagesDataSource" EditMode="InPlace"
        <CommandItemTemplate> 
            <div style="padding: 0 5px;"
                <asp:LinkButton ID="btnCancel" runat="server" CommandName="CancelAll" CausesValidation="false" 
                    Visible='<%# RadGrid1.EditIndexes.Count > 0 %>'><img style="border:0px;vertical-align:middle;" alt="" src="./Img/Cancel.gif" />Cancel</asp:LinkButton>&nbsp;&nbsp; 
                <asp:LinkButton ID="Add" runat="server" CommandName="InitInsert" CausesValidation="false" 
                    Enabled='<%# !RadGrid1.MasterTableView.IsItemInserted %>'><img style="border:0px;vertical-align:middle;" alt="" src="/Img/AddRecord.gif" />Add Telephony Enviroment</asp:LinkButton>&nbsp;&nbsp; 
                <asp:LinkButton ID="LinkButton1" CausesValidation="false" OnClientClick="javascript:return confirm('Delete Selected package?')" 
                    runat="server" CommandName="DeleteSelected"><img style="border:0px;vertical-align:middle;" alt="" src="/Img/Delete.gif" />Delete</asp:LinkButton>&nbsp;&nbsp; 
                <asp:LinkButton ID="LinkButton3" runat="server" CausesValidation="false" CommandName="PerformInsert" 
                    Visible='<%# RadGrid1.MasterTableView.IsItemInserted %>'>Add this Customer</asp:LinkButton>&nbsp;&nbsp; 
            </div> 
        </CommandItemTemplate> 
        <RowIndicatorColumn> 
            <HeaderStyle Width="20px"></HeaderStyle> 
        </RowIndicatorColumn> 
        <ExpandCollapseColumn> 
            <HeaderStyle Width="20px"></HeaderStyle> 
        </ExpandCollapseColumn> 
        <Columns> 
            <telerik:GridBoundColumn DataField="iPackageId" DataType="System.Int32" HeaderText="iPackageId" 
                ReadOnly="True" SortExpression="iPackageId" UniqueName="iPackageId" Display="false" 
                ForceExtractValue="None"
            </telerik:GridBoundColumn> 
            <telerik:GridDropDownColumn DataSourceID="PackageTypesDataSource" SortExpression="iPackageType" 
                UniqueName="" DataField="iPackageType" meta:resourcekey="RESX_iPackageType" ListValueField="iPackageTypeID" 
                ListTextField="nvcPackageName" DropDownControlType="RadComboBox"
            </telerik:GridDropDownColumn> 
            <telerik:GridBoundColumn DataField="nvcPackageName" HeaderText="nvcPackageName" SortExpression="nvcPackageName" 
                UniqueName="nvcPackageName" Display="true" meta:resourcekey="RESX_nvcPackageName"
            </telerik:GridBoundColumn> 
            <telerik:GridBoundColumn DataField="iSwitchID" DataType="System.Int32" HeaderText="iSwitchID" 
                SortExpression="iSwitchID" UniqueName="iSwitchID" Display="false"
            </telerik:GridBoundColumn> 
            <telerik:GridBoundColumn DataField="iWizardStep" DataType="System.Int32" HeaderText="iWizardStep" 
                SortExpression="iWizardStep" UniqueName="iWizardStep" Display="false"
            </telerik:GridBoundColumn> 
            <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete"
            </telerik:GridButtonColumn> 
        </Columns> 
        <EditFormSettings CaptionDataField="iCaptureId"
            <FormTableItemStyle Width="100%" Height="29px"></FormTableItemStyle> 
            <FormTableStyle GridLines="None" CellSpacing="0" CellPadding="2"></FormTableStyle> 
            <FormStyle Width="100%" BackColor="#eef2ea"></FormStyle> 
            <EditColumn ButtonType="ImageButton" /> 
        </EditFormSettings> 
    </MasterTableView> 
    <SelectedItemStyle BorderWidth="1px" Font-Bold="True" Wrap="True" /> 
    <ClientSettings> 
        <ClientEvents OnRowSelected="RowSelected" /> 
        <Selecting AllowRowSelect="True" /> 
    </ClientSettings> 
    <FilterMenu EnableTheming="True"
        <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
    </FilterMenu> 
</telerik:RadGrid> 
<asp:ObjectDataSource ID="PackagesDataSource" runat="server" DeleteMethod="Delete" 
    InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="Fill" 
    TypeName="NPEWebApplication.Configurations.RecordingConfiguration.CustomDataSources.PackageDataSource" 
    UpdateMethod="Update"
    <DeleteParameters> 
        <asp:Parameter Name="iPackageId" Type="String" /> 
        <asp:Parameter Name="original_iPackageId" Type="Int32" /> 
    </DeleteParameters> 
    <UpdateParameters> 
        <asp:Parameter Name="iPackageType" Type="Int32" /> 
        <asp:Parameter Name="nvcPackageName" Type="String" /> 
        <asp:Parameter Name="iSwitchID" Type="Int32" /> 
        <asp:Parameter Name="iWizardStep" Type="Int32" /> 
        <asp:Parameter Name="original_iPackageId" Type="Int32" /> 
    </UpdateParameters> 
    <InsertParameters> 
        <asp:Parameter Name="iPackageId" Type="Int32" /> 
        <asp:Parameter Name="iPackageType" Type="Int32" /> 
        <asp:Parameter Name="nvcPackageName" Type="String" /> 
        <asp:Parameter Name="iSwitchID" Type="Int32" /> 
        <asp:Parameter Name="iWizardStep" Type="Int32" /> 
    </InsertParameters> 
</asp:ObjectDataSource> 
<asp:ObjectDataSource ID="PackageTypesDataSource" runat="server" OldValuesParameterFormatString="original_{0}" 
    SelectMethod="Fill" TypeName="NPEWebApplication.Configurations.RecordingConfiguration.CustomDataSources.PackageTypesDataSource"
</asp:ObjectDataSource> 
<asp:HiddenField runat="server" ID="hdnSelectedIndex" Value="-1" /> 
 
<script language="javascript" type="text/javascript"
    function RowSelected(sender, eventArgs) { 
        var indexField = document.getElementById("<%=hdnSelectedIndex.ClientID %>"); 
        if (indexField) { 
            indexField.value = getDataItemKeyValue(sender, eventArgs.get_gridDataItem()); 
        } 
        alert(indexField.value); 
    } 
    function getDataItemKeyValue(radGrid, item) { 
        alert("hey"); 
        alert(radGrid.get_masterTableView().getCellByColumnUniqueName(item, "iPackageId")); 
        return parseInt(radGrid.get_masterTableView().getCellByColumnUniqueName(item, "iPackageId").innerHTML); 
    } 
</script> 
 
 

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 12 Jan 2009, 02:46 PM
Hello Hadar,

I recommend you check whether eventArgs.get_gridDataItem() is not null in the following line:
getDataItemKeyValue(sender, eventArgs.get_gridDataItem()); 

Please examine the document shown below:
Getting familiar with client-side API

"Important note: For performance reasons, the <GridTableViewInstance>.get_dataItems() collection will be available only when you enable specific client features/events for the rows in the grid (such AllowRowResize, AllowRowSelect, OnRowClick, etc.)."

Best regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Hk
Top achievements
Rank 2
Answers by
Daniel
Telerik team
Share this question
or