iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
I am using a button click to create a new row, default the row's data, and then the row's Select() method to select the row and scroll into focus. The problem is that if there are rows not loaded (i.e. 200 of 350), the grid attempts to postback to get more data. How do I prevent that from happening for that situation?
Based on the snippet you provided, you are using BatchUpdate feature and VirtualLoad paging. Under such scenario, you could set the Grid property HaltLoadMore set to true in order to abort the load more process once. In your case, you will need to set the property before invoking the Select or ActivateEdit method. Here is the snippet:
function AddRow(){ var grid = ISGetObject("WebGrid1"); var newRow = grid.RootTable.NewRow(); // create new row object var cells = newRow.GetCells(); // get WebGridCell collection // populate new row object . . . // insert new record newRow.AddPendingChanges(); grid.HaltLoadMore = true newRow.GetCell(0).ActivateEdit(); }
In my test, the Select function will return error if the row is not in the displayed view. My workaround is to use the GetRowByKeyValue function to check if the newly added row is in the displayed view. If the row is not displayed this function will return null.
Based on your description, I think the scroll into focus script that cause the postback to get more data. Do you mind sharing the code snippet so we could do further testing?
In my test, the Select function will return error if the row is not in the displayed view. My workaround is to use the GetRowByKeyValue function to check if the newly added row is in the displayed view. If the row is not displayed this function will return null.Based on your description, I think the scroll into focus script that cause the postback to get more data. Do you mind sharing the code snippet so we could do further testing?
Sure.
I tried both the New Row's Select() Method and the New Row's 1st editable cell's ActivateEdit() method. It focuses the field and if there is more data available, a postback occurs from the grid.
function AddNewInuring() { try { // Get grid var grdInurings = ISGetObject("<%=this.grdInurings.ClientID%>"); if (grdInurings == null) { return false; } // Create new row var newRow = grdInurings.RootTable.NewRow(); if (newRow == null) { return false; } // Default new row's data // NOTE: Scroll to row before new row to avoid lag from WebGrid loading more data (if exist) grdInurings.ClearSelection(); DefaultNewInuringRow(newRow); newRow.AddPendingChanges(); // Focus var treatyName = newRow.GetCells().GetNamedItem("<%=Endurance.Re.AWB.Utility.AWBConstants.SP_COL_INURING_GET_TREATYNAME%>"); if (treatyName != null) { treatyName.ActivateEdit(); } return true; } catch (ex) { ShowJSException(ex); } } function DefaultNewInuringRow(row) { try { if (row == null) { return; } // Selected var cells = row.GetCells(); if (cells == null) { return; } var selected = cells.GetNamedItem("<%=Endurance.Re.AWB.Utility.AWBConstants.SP_COL_INURING_GET_ISSELECTED%>"); if (selected != null) { selected.SetValue(false, true); } // Treaty Name var treatyName = cells.GetNamedItem("<%=Endurance.Re.AWB.Utility.AWBConstants.SP_COL_INURING_GET_TREATYNAME%>"); if (treatyName != null) { WebGrid_SetFieldText(treatyName, ""); } // Portfolio Name List UpdatePortfolioData(row, null); // Cedant Name var cedantName = cells.GetNamedItem("<%=Endurance.Re.AWB.Utility.AWBConstants.SP_COL_INURING_GET_CEDANTNAME%>"); if (cedantName != null) { WebGrid_SetFieldText(cedantName, ""); } // Inuring Structure var inuringStructure = cells.GetNamedItem("<%=Endurance.Re.AWB.Utility.AWBConstants.SP_COL_INURING_GET_INURINGTYPE_ID%>"); if (inuringStructure != null) { WebGrid_SetDropDownListValue(inuringStructure, "<%=Endurance.Re.Common.Data.CommonConstants.DROPDOWN_VALUE_SELECT%>", "<%=Endurance.Re.Common.Data.CommonConstants.DROPDOWN_ID_SELECT%>"); } // Currency Code var currencyCode = cells.GetNamedItem("<%=Endurance.Re.AWB.Utility.AWBConstants.SP_COL_INURING_GET_CURRENCYCODE%>"); if (currencyCode != null) { WebGrid_SetFieldText(currencyCode, "<%=Endurance.Re.AWB.Utility.AWBConstants.INURING_CURRENCYCODE_DEFAULT_VALUE%>"); } // Occurrency Limit var occurrenceLimit = cells.GetNamedItem("<%=Endurance.Re.AWB.Utility.AWBConstants.SP_COL_INURING_GET_OCCURRENCELIMIT%>"); if (occurrenceLimit != null) { WebGrid_SetFieldText(occurrenceLimit, "0"); } // Attachment var attachment = cells.GetNamedItem("<%=Endurance.Re.AWB.Utility.AWBConstants.SP_COL_INURING_GET_ATTACHMENT%>"); if (attachment != null) { WebGrid_SetFieldText(attachment, "0"); } // Risk Limit var riskLimit = cells.GetNamedItem("<%=Endurance.Re.AWB.Utility.AWBConstants.SP_COL_INURING_GET_RISKLIMIT%>"); if (riskLimit != null) { WebGrid_SetFieldText(riskLimit, "0"); } // Retention var retention = cells.GetNamedItem("<%=Endurance.Re.AWB.Utility.AWBConstants.SP_COL_INURING_GET_RETENTION%>"); if (retention != null) { WebGrid_SetFieldText(retention, "0"); } // Placed var placed = cells.GetNamedItem("<%=Endurance.Re.AWB.Utility.AWBConstants.SP_COL_INURING_GET_PLACED%>"); if (placed != null) { WebGrid_SetFieldText(placed, "0"); } // Covered var covered = cells.GetNamedItem("<%=Endurance.Re.AWB.Utility.AWBConstants.SP_COL_INURING_GET_COVERED%>"); if (covered != null) { WebGrid_SetFieldText(covered, "0"); } // Effective Date var effectiveDate = cells.GetNamedItem("<%=Endurance.Re.AWB.Utility.AWBConstants.SP_COL_INURING_GET_EFFECTIVEDATE%>"); if (effectiveDate != null) { WebGrid_SetFieldText(effectiveDate, ""); } // Expiration Date var expirationDate = cells.GetNamedItem("<%=Endurance.Re.AWB.Utility.AWBConstants.SP_COL_INURING_GET_EXPIRATIONDATE%>"); if (expirationDate != null) { WebGrid_SetFieldText(expirationDate, ""); } // Premium var premium = cells.GetNamedItem("<%=Endurance.Re.AWB.Utility.AWBConstants.SP_COL_INURING_GET_PREMIUM%>"); if (premium != null) { WebGrid_SetFieldText(premium, "0"); } // Coverage Basis var coverageBasis = cells.GetNamedItem("<%=Endurance.Re.AWB.Utility.AWBConstants.SP_COL_INURING_GET_COVERAGEBASISTYPE_ID%>"); if (coverageBasis != null) { WebGrid_SetDropDownListValue(coverageBasis, "<%=Endurance.Re.Common.Data.CommonConstants.DROPDOWN_VALUE_SELECT%>", "<%=Endurance.Re.Common.Data.CommonConstants.DROPDOWN_ID_SELECT%>"); } // Attachment Basis var attachmentBasis = cells.GetNamedItem("<%=Endurance.Re.AWB.Utility.AWBConstants.SP_COL_INURING_GET_ATTACHMENTBASISTYPE_ID%>"); if (attachmentBasis != null) { WebGrid_SetDropDownListValue(attachmentBasis, "<%=Endurance.Re.Common.Data.CommonConstants.DROPDOWN_VALUE_SELECT%>", "<%=Endurance.Re.Common.Data.CommonConstants.DROPDOWN_ID_SELECT%>"); } // Priority var priority = cells.GetNamedItem("<%=Endurance.Re.AWB.Utility.AWBConstants.SP_COL_INURING_GET_PRIORITY%>"); if (priority != null) { WebGrid_SetFieldText(priority, "1"); } // Number of Reinstatements var numReinstatements = cells.GetNamedItem("<%=Endurance.Re.AWB.Utility.AWBConstants.SP_COL_INURING_GET_NUMREINSTATEMENTS%>"); if (numReinstatements != null) { WebGrid_SetFieldText(numReinstatements, "1"); } // Reinstatement Charge var reinstatementCharge = cells.GetNamedItem("<%=Endurance.Re.AWB.Utility.AWBConstants.SP_COL_INURING_GET_REINSTATEMENTCHARGE%>"); if (reinstatementCharge != null) { WebGrid_SetFieldText(reinstatementCharge, "0"); } // Source var source = cells.GetNamedItem("<%=Endurance.Re.AWB.Utility.AWBConstants.SP_COL_INURING_GET_SOURCE%>"); if (source != null) { WebGrid_SetFieldText(source, "<%=Endurance.Re.AWB.Utility.AWBConstants.INURING_SOURCE_USER_DEFAULT_TEXT%>"); } // Inuring Notes var inuringNotes = cells.GetNamedItem("<%=Endurance.Re.AWB.Utility.AWBConstants.SP_COL_INURING_GET_INURINGNOTES%>"); if (inuringNotes != null) { WebGrid_SetFieldText(inuringNotes, ""); } // ID // NOTE: This is done to avoid any validation on the DataKeyField being unique var id = cells.GetNamedItem("<%=Endurance.Re.AWB.Utility.AWBConstants.SP_COL_INURING_GET_ID%>"); if (id != null) { var now = new Date(); WebGrid_SetFieldText(id, (now.getSeconds() + now.getMilliseconds())); } } catch (ex) { ShowJSException(ex); } }
<CommonCtrl:EnduranceWebGrid runat="server" ID="grdInurings" DefaultStyleMode="Elegant" UseDefaultStyle="True" Width="100%" Height="100%" ViewStateItems="All" OnInitializeDataSource="grdInurings_OnInitializeDataSource" OnInitializePostBack="grdInurings_OnInitializePostBack" OnPrepareDataBinding="grdInurings_OnPrepareDataBinding" OnInitializeLayout="grdInurings_OnInitializeLayout" OnInitializeRow="grdInurings_OnInitializeRow" OnUpdateRow="grdInurings_OnUpdateRow" OnExport="grdInurings_OnExport"> <LayoutSettings AutoHeight="false" AutoWidth="false" AllowBatchUpdate="true" BatchUpdateSettings-PromptUnsavedChanges="false" BatchUpdateSettings-AutomaticObjectUpdate="false" AllowEdit="Yes" EditOnClick="True" AllowAddNew="Yes" AllowDelete="Yes" PromptBeforeDelete="true" NewRowLostFocusAction="AlwaysPrompt" ResetNewRowValuesOnError="True" RowHeightDefault="22px" AllowFilter="Yes" AllowSelectColumns="Yes" AllowSorting="Yes" HideColumnsWhenGrouped="Default" AllowExport="Yes" InProgressUIBehavior="ChangeCursorToHourGlass" ApplyFiltersKey="Enter" AllowColumnFreezing="Yes" ShowFilterStatus="True" PagingMode="VirtualLoad" VerboseEditingInformation="False" FilterBarVisible="True" PagingExportMode="ExportAllData" CellPaddingDefault="0" AlwaysShowHelpButton="False" VirtualPageSize="200"> <ClientSideEvents OnInitialize="grdInurings_OnInitialize" OnRowContextMenu="grdInurings_OnRowContextMenu" OnRowValidate="grdInurings_OnRowValidate" OnRowSelect="grdInurings_OnRowSelect" /> <FrameStyle> <BorderSettings> <Top Style="none" /> <Bottom Style="none" /> <Left Color="#6593cf" Width="1" Style="solid" /> <Right Color="#6593cf" Width="1" Style="solid" /> </BorderSettings> </FrameStyle> <HeaderStyle CssClass="WebGridHeaderStyle" /> <StatusBarStyle CssClass="WebGridStatusBarStyle" /> <StatusBarCommandStyle Active-CssClass="WebGridStatusBarCommandStyleActive" Normal-CssClass="WebGridStatusBarCommandStyleNormal" Over-CssClass="WebGridStatusBarCommandStyleOver"> <Normal CssClass="WebGridStatusBarCommandStyleNormal"> </Normal> <Over CssClass="WebGridStatusBarCommandStyleOver"> </Over> <Active CssClass="WebGridStatusBarCommandStyleActive"> </Active> </StatusBarCommandStyle> <FilterRowStyle CssClass="WebGridFilterRowStyle" /> <PreviewRowStyle CssClass="WebGridRowStyle" /> <RowStyle CssClass="WebGridRowStyle" /> <QuickFilterBarStyle CssClass="WebGridRowStyle" /> <RowHeaderStyle CssClass="WebGridRowHeaderStyle" /> <SelectedRowStyle CssClass="WebGridSelectedRowStyle" /> <EditFocusCellStyle CssClass="WebGridRowStyle" /> <FocusCellStyle CssClass="WebGridRowStyle" /> <LostFocusRowStyle CssClass="WebGridRowStyle" /> <NewRowStyle CssClass="WebGridRowStyle" /> <SortedColumnStyle CssClass="WebGridSortedColumnStyle" /> <AlternatingRowStyle CssClass="WebGridAlternatingRowStyle" /> <EditTextboxStyle CssClass="WebGridEditTextboxStyle" /> <FreezePaneSettings ActiveFrozenColumns="4" ShowInContextMenu="False" ShowSplitterLine="False" MaxFrozenColumns="4" SplitterLineColor="ActiveBorder" SplitterLineWidth="1" /> </LayoutSettings> <RootTable Caption="Inurings" DataKeyField="ID" NewRowInfoText="Please click here to create a new Inuring"> <Columns> <ISWebGrid:WebGridColumn Caption="ID" Name="ID" DataMember="ID" DataType="System.Integer" ColumnType="Text" EditType="NoEdit" NewRowEditType="NoEdit" FilterEditType="NoEdit" Width="0px" Visible="false"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="IsReadOnly" Name="IsReadOnly" DataMember="IsReadOnly" DataType="System.Boolean" ColumnType="Text" EditType="NoEdit" NewRowEditType="NoEdit" FilterEditType="NoEdit" Width="0px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="Select" Name="IsSelected" DataMember="IsSelected" DataType="System.Boolean" ColumnType="CheckBox" EditType="Checkbox" NewRowEditType="Checkbox" FilterEditType="Checkbox" Width="40px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="Treaty Name" Name="TreatyName" DataMember="TreatyName" DataType="System.String" ColumnType="Text" EditType="TextBox" NewRowEditType="TextBox" FilterEditType="TextBox" Width="150px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="Portfolio Name" Name="PortfolioNameList" DataMember="PortfolioNameList" DataType="System.String" ColumnType="Text" EditType="NoEdit" NewRowEditType="NoEdit" FilterEditType="TextBox" Width="100px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="PortfolioIDList" Name="PortfolioIDList" DataMember="PortfolioIDList" DataType="System.String" ColumnType="Text" EditType="NoEdit" NewRowEditType="NoEdit" FilterEditType="NoEdit" Width="0px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="Cedant" Name="CedantName" DataMember="CedantName" DataType="System.String" ColumnType="Text" EditType="TextBox" NewRowEditType="TextBox" FilterEditType="TextBox" Width="100px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="Inuring Structure" Name="InuringTypeID" DataMember="InuringTypeID" DataType="System.Integer" ColumnType="Custom" EditType="DropdownList" NewRowEditType="DropdownList" FilterEditType="DropdownList" Width="100px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="Currency" Name="CurrencyCode" DataMember="CurrencyCode" DataType="System.String" ColumnType="Custom" EditType="DropdownList" NewRowEditType="DropdownList" FilterEditType="DropdownList" Width="70px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="Occurrence Limit" Name="OccurrenceLimit" DataMember="OccurrenceLimit" DataType="System.Integer" ColumnType="Text" EditType="TextBox" NewRowEditType="TextBox" FilterEditType="TextBox" Width="100px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="Attachment" Name="Attachment" DataMember="Attachment" DataType="System.Integer" ColumnType="Text" EditType="TextBox" NewRowEditType="TextBox" FilterEditType="TextBox" Width="100px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="Risk Limit" Name="RiskLimit" DataMember="RiskLimit" DataType="System.Integer" ColumnType="Text" EditType="TextBox" NewRowEditType="TextBox" FilterEditType="TextBox" Width="100px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="Retention" Name="Retention" DataMember="Retention" DataType="System.Integer" ColumnType="Text" EditType="TextBox" NewRowEditType="TextBox" FilterEditType="TextBox" Width="100px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="%Placed" Name="Placed" DataMember="Placed" DataType="System.Decimal" ColumnType="Text" EditType="TextBox" NewRowEditType="TextBox" FilterEditType="TextBox" Width="100px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="%Covered" Name="Covered" DataMember="Covered" DataType="System.Decimal" ColumnType="Text" EditType="TextBox" NewRowEditType="TextBox" FilterEditType="TextBox" Width="100px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="Effective Date" Name="EffectiveDate" DataMember="EffectiveDate" DataFormatString="dd-MMM-yyyy" DataType="System.String" ColumnType="Text" EditType="CalendarCombo" NewRowEditType="CalendarCombo" FilterEditType="CalendarCombo" Width="90px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="Expiry Date" Name="ExpirationDate" DataMember="ExpirationDate" DataFormatString="dd-MMM-yyyy" DataType="System.String" ColumnType="Text" EditType="CalendarCombo" NewRowEditType="CalendarCombo" FilterEditType="CalendarCombo" Width="90px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="Premium" Name="Premium" DataMember="Premium" DataType="System.Integer" ColumnType="Text" EditType="TextBox" NewRowEditType="TextBox" FilterEditType="TextBox" Width="100px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="Coverage Basis" Name="CoverageBasisTypeID" DataMember="CoverageBasisTypeID" DataType="System.Integer" ColumnType="Custom" EditType="DropdownList" NewRowEditType="DropdownList" FilterEditType="DropdownList" Width="100px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="Attachment Basis" Name="AttachmentBasisTypeID" DataMember="AttachmentBasisTypeID" DataType="System.Integer" ColumnType="Custom" EditType="DropdownList" NewRowEditType="DropdownList" FilterEditType="DropdownList" Width="100px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="Priority" Name="Priority" DataMember="Priority" DataType="System.DateTime" ColumnType="Text" EditType="TextBox" NewRowEditType="TextBox" FilterEditType="TextBox" Width="50px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="Number of Reinstatements" Name="NumReinstatements" DataMember="NumReinstatements" DataType="System.DateTime" ColumnType="Text" EditType="TextBox" NewRowEditType="TextBox" FilterEditType="TextBox" Width="150px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="Reinstatement Charge" Name="ReinstatementCharge" DataMember="ReinstatementCharge" DataType="System.DateTime" ColumnType="Text" EditType="TextBox" NewRowEditType="TextBox" FilterEditType="TextBox" Width="125px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="Source" Name="Source" DataMember="Source" DataType="System.String" ColumnType="Text" EditType="NoEdit" NewRowEditType="NoEdit" FilterEditType="TextBox" Width="50px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="Notes" Name="InuringNotes" DataMember="InuringNotes" DataType="System.String" ColumnType="Text" EditType="TextBox" NewRowEditType="TextBox" FilterEditType="TextBox" Width="300px"> </ISWebGrid:WebGridColumn> </Columns> </RootTable> </CommonCtrl:EnduranceWebGrid>
Based on the snippet you provided, you are using BatchUpdate feature and VirtualLoad paging. Under such scenario, you could set the Grid property HaltLoadMore set to true in order to abort the load more process once. In your case, you will need to set the property before invoking the Select or ActivateEdit method. Here is the snippet:function AddRow(){ var grid = ISGetObject("WebGrid1"); var newRow = grid.RootTable.NewRow(); // create new row object var cells = newRow.GetCells(); // get WebGridCell collection // populate new row object . . . // insert new record newRow.AddPendingChanges(); grid.HaltLoadMore = true newRow.GetCell(0).ActivateEdit(); }
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname