locked
navigateThroughCells is not defined error RRS feed

  • Question

  • User-1506965535 posted

    I am using one of the Javascript function on onkeypress but i am getting error as

     navigateThroughCells is not defined 

    Here is my JS code function:-

    function navigateThroughCells(sender, key, forced) {
        if (forced && focusedGrid != null) {
            focusedGrid._keyNavigationIsEnabled = true;
        }
    
        if (focusedGrid._keyNavigationIsEnabled || forced) {
            var currentCell = focusedGrid._lastEditedField.parentNode.parentNode.parentNode;
            var currentCellIndex = 0;
            var tempCell = currentCell.previousSibling;
            while (tempCell) {
                currentCellIndex++;
                tempCell = tempCell.previousSibling;
            }
            var newCell = null;
            switch (key) {
                case 37:
                    if (currentCell.previousSibling) {
                        newCell = currentCell.previousSibling;
                    }
                    break;
                case 38:
                    if (currentCell.parentNode.previousSibling) {
                        newCell = currentCell.parentNode.previousSibling.childNodes[currentCellIndex];
                    }
                    break;
                case 39:
                    if (currentCell.nextSibling) {
                        newCell = currentCell.nextSibling;
                    }
                    break;
                case 40:
                    if (currentCell.parentNode.nextSibling) {
                        newCell = currentCell.parentNode.nextSibling.childNodes[currentCellIndex];
                    }
                    break;
                default:
                    focusedGrid._keyNavigationIsEnabled = false;
                    if (key == 13 || key == 27 || key == 113) {
                        if (typeof (focusedGrid._lastEditedFieldEditor.value) == 'function') {
                            var previousValue = focusedGrid._lastEditedFieldEditor.value();
                            focusedGrid._lastEditedFieldEditor.value('');
                            focusedGrid._lastEditedFieldEditor.value(previousValue);
                        }
                    }
                    break;
            }
    
            if (newCell) {
                var textboxes = newCell.firstChild.firstChild.getElementsByTagName('INPUT');
                if (textboxes.length) {
                    textboxes[0].focus();
                }
            }
        } else {
            if (key == 13 || key == 27) {
                focusedGrid._keyNavigationIsEnabled = true;
                focusedGrid.selectLastFieldEditor();
    
                if (key == 13) {
                    if (typeof (focusedGrid._lastEditedFieldEditor.value) == 'function') {
                        focusedGrid._lastEditedFieldEditorValue = focusedGrid._lastEditedFieldEditor.value();
                    } else {
                        focusedGrid._lastEditedFieldEditorValue = focusedGrid._lastEditedFieldEditor.checked();
                    }
                } else if (focusedGrid != null && focusedGrid._lastEditedFieldEditorValue != null) {
                    window.setTimeout(function () { focusedGrid.restoreEditorValue(); }, 10);
                }
            }
        }
    
        if (key == 13 || key == 27) {
            return false;
        }
    
        return true;
    }

    I am using that function in my gridview, have a look here

    <cc1:Grid ID="GrdConfirmation" EnableTypeValidation="true" runat="server" Width="100%"
            ShowFooter="false" AllowAddingRecords="true" AllowSorting="false" AutoGenerateColumns="false"
            FolderStyle="../Styles/Grid/style_12" OnRowDataBound="GrdConfirmation_RowDataBound">
            <ClientSideEvents OnClientSelect="FunClickTest" />
            <Columns>
                <cc1:CheckBoxSelectColumn ShowHeaderCheckBox="true" ControlType="Standard" Width="5%">
                </cc1:CheckBoxSelectColumn>
                <cc1:Column ID="Column1" DataField="MKEY" HeaderText="Select" ReadOnly="true" Width="5%"
                    runat="server">
                    <TemplateSettings TemplateId="TemplateWithCheckbox" />
                </cc1:Column>
                <cc1:Column ID="Sr_No" DataField="Sr_No" HeaderText="Sr No" Visible="true" Width="5%">
                    <TemplateSettings TemplateId="tplNumbering" />
                </cc1:Column>
                <cc1:Column ID="Line_Id" DataField="Line_Id" HeaderText="Line id" Visible="true"
                    Align="center" Width="5%">
                </cc1:Column>
                <cc1:Column ID="Item_Mkey" DataField="Item_Mkey" HeaderText="Item Mkey" Visible="true"
                    Align="center" Width="5%">
                </cc1:Column>
                <cc1:Column ID="Item_Code" DataField="Item_Code" HeaderText="Item Code" Visible="true"
                    Align="center" Width="5%">
                </cc1:Column>
                <cc1:Column ID="ITEM_DESC" DataField="ITEM_DESC" HeaderText="Item Description" Visible="true"
                    Align="center" Width="10%">
                </cc1:Column>
                <cc1:Column ID="Lot_Batch_No" DataField="Lot_Batch_No" HeaderText="Lot / Batch No."
                    Visible="true" Align="center" Width="5%">
                </cc1:Column>
                <cc1:Column ID="Exp_Dt" DataField="Exp_Dt" HeaderText="Exp Date" Visible="true" Align="center"
                    Width="5%">
                </cc1:Column>
                <cc1:Column ID="QTY1" DataField="Qty" HeaderText=" Quantity" Visible="true" Width="5%"
                    Align="center">
                </cc1:Column>
                <cc1:Column ID="Bx_Bg" DataField="Bx_Bg" HeaderText="Boxes/Bags" Visible="true" Width="5%"
                    Align="center">
                </cc1:Column>
                <cc1:Column ID="Net_Wgt" DataField="Net_Wgt" HeaderText="Net Weight" Visible="true"
                    Width="5%" Align="center">
                </cc1:Column>
                <cc1:Column ID="NO_OF_PALLETS" DataField="NO_OF_PALLETS" HeaderText="No Of Pallets"
                    Visible="true" Align="center" Width="5%">
                </cc1:Column>
                <cc1:Column ID="Default_Allot" DataField="Default_Allot" HeaderText="Allocated Storage Bin No."
                    Visible="true" Width="5%" Align="right">
                </cc1:Column>
                <cc1:Column ID="Confirmed_Allot" DataField="Confirmed_Allot" HeaderText="Confirmed Storage Bin No."
                    Visible="true" Width="5%" Align="right">
                    <TemplateSettings TemplateId="TextBoxEditTemplate" />
                </cc1:Column>
                <cc1:Column ID="DAMAGED_QTY" DataField="DAMAGED_QTY" HeaderText="Damaged Qty in Units"
                    Visible="true" Width="5%" Align="right">
                </cc1:Column>
                <cc1:Column ID="SHORTFALL_QTY" DataField="SHORTFALL_QTY" HeaderText="Shortfall/ excess qty in units"
                    Visible="true" Width="5%" Align="right">
                </cc1:Column>
            </Columns>
            <AddEditDeleteSettings AddLinksPosition="Bottom" NewRecordPosition="Dynamic" />
            <Templates>
                <cc1:GridTemplate runat="server" ID="tplNumbering">
                    <Template>
                        <b>
                            <%# (Container.RecordIndex + 1) %></b>
                    </Template>
                </cc1:GridTemplate>
                <cc1:GridTemplate ID="TemplateWithCheckbox">
                    <Template>
                        <asp:CheckBox runat="server" ID="ChkID" ToolTip="<%# Container.Value %>" />
                    </Template>
                </cc1:GridTemplate>
                <cc1:GridTemplate runat="server" ID="TextBoxEditTemplate">
                    <Template>
                        <input type="text" name="TextBox1" class="excel-textbox" value='<%# Container.Value %>'
                            readonly="readonly" onfocus="GrdConfirmation.editWithTextBox(this)" />
                    </Template>
                </cc1:GridTemplate>
            </Templates>
        </cc1:Grid>
        <div style="display: none;" id="FieldEditorsContainer">
            <div id="TextBoxEditorContainer" style="width: 100%">
                <cc1:OboutTextBox runat="server" ID="TextBoxEditor" FolderStyle="../Interfaces/Styles/premiere_blue/OboutTextBox"
                    Width="100%" AutoCompleteType="None">
                    <ClientSideEvents OnKeyDown="navigateThroughCells" />  // this is what giving me error.
                </cc1:OboutTextBox>
            </div>
        </div>

    Please suggest what to do here

    Wednesday, October 7, 2015 2:04 AM

Answers

All replies

  • User475983607 posted

    Is the navigateThroughCells contained in a JS file?  If so, use Developer tools to verify you're not receiving 404 errors.  

    This can also happen if the function is within a JQuery ready events.  If he function, navigateThroughCells, is a local member of the $ready anonymous function, it cannot be called outside the ready events.  If this is the case then move the functions outside $ready and into global scope.

     

    Wednesday, October 7, 2015 7:40 AM
  • User-1506965535 posted

     If this is the case then move the functions outside $ready and into global scope.

    I tried changing the order of the JS file and got resolved that issue. But one another issue which was occuring in IE was

    the error as 

    Line: 309

    Error: 'Obout.Interface.OboutTextBox' is null or not an object

    Here is my jsfiddle;- http://jsfiddle.net/norlihazmeyGhazali/de2nh862

    Wednesday, October 7, 2015 7:59 AM
  • User475983607 posted

    Line: 309

    Error: 'Obout.Interface.OboutTextBox' is null or not an object

    The error is saying the expected object, Obout, does not exist.  Why it does not exist is not clear from your code snippet on jsFiddle.

    Have you considered contacting Obout support since you are doing fairly complicated JavaScript OOP programming with this 3rd party library.

    Wednesday, October 7, 2015 9:00 AM
  • User61956409 posted

    Hi Nadeem,

    the error as 

    Line: 309

    Error: 'Obout.Interface.OboutTextBox' is null or not an object

    It seems that you resolve the problem from this.

     http://stackoverflow.com/questions/32985356/obout-interface-obouttextbox-is-null-or-not-an-object-error

    Best Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 8, 2015 4:57 AM
  • User475983607 posted

    Wow, I gave you the same advice on your other thread with the same subject...

    http://forums.asp.net/t/2070184.aspx?Jquery+null+or+not+an+object+error

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 8, 2015 5:54 AM
  • User-1506965535 posted

    I m sorry i was much busy with the issue, forgot to mark it as answer :)

    Thanks a lot

    Thursday, October 8, 2015 6:01 AM