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
Currently I'm using the WebGrid in a modalbox as lookup. The Grid doesn't have a datasource assigned, because it's filled from clientside. The user can't interact with the grid in any way; only to select a row.
Each search action will fill the grid from clientside. However, before each search action, I'd like to empty the grid. I tried this:
var grid = ISGetObject("SearchResultsWebGrid"); for(var i = 0; i < grid.RootTable.GetRowsCount(); i++) { grid.RootTable.GetRow(i).Delete(); } grid.RootTable.UpdateUI()
However, it's not giving me javascript warnings or other errors. And, it doesn't remove any rows... I searched this website for a solution, but couldn't find it so far.
Anyone got a solution or an idea how to truncate (delete all rows) from a webgrid at clientside?
Thanks!
Hi Herman,
I don't know if you are using BatchUpdate scenario. Normally, using Delete() method will delet the row. Delete operation will need a process time. So if you don't use delay/timeout, sometimes it will give you an alert 'Please wait, WebGrid is doing a process". But your scenario doesn't need this because it is SmartBatchUpdate scenario. In SmartBacthUpdate scenario, normally the changes have not been saved in database when you don't use AcceptPendingChanges. But you can Undo the changes to undo the inserted rows. If you call Undo changes, I am sure the rows should be removed.
Regards,Handy
Hello Herman,
grid.RootTable.GetRow(i).Delete(); should be able to delete the rows. But I think you will need to use delay/timeout. Each delete operations would need a time to finish. You mentioned that fill the grid from clientside. Does it mean you use clientbinding? Please let me know more detail about this scenario. If it is possible, please send me a simple sample about this issue.
Hi Handy,
Thanks again for a reply. I'll have a look what you mean by delay/timeout. For the moment, answers to your questions:
No I don't use clientbinding. From an AJAX response call to search my database, I fill the grid with the results as follows:
function searchCompleted(result) { var grid = ISGetObject("SearchResultsWebGrid"); if(result != null) { for(var i = 0; i < result.length; i++) { var newRow = grid.RootTable.NewRow(); newRow.KeyValue = result[i][0]; var cells = newRow.GetCells(); cells.GetNamedItem("UserName").SetText(result[i][1], true); cells.GetNamedItem("FullName").SetText(result[i][2], true); cells.GetNamedItem("PhoneNumber").SetText(result[i][3], true); cells.GetNamedItem("MobilePhoneNumber").SetText(result[i][4], true); cells.GetNamedItem("EmailAddress").SetText(result[i][5], true); cells.GetNamedItem("Department").SetText(result[i][6], true); newRow.AddPendingChanges(); } } }
My grid definition:
<ISWebGrid:WebGrid ID="SearchResultsWebGrid" runat="server" Width="100%" Height="493px" UseDefaultStyle="True" DefaultStyleMode="Win7"> <LayoutSettings AllowBatchUpdate="True" AllowAddNew="Yes" AllowEdit="No" AllowDelete="Yes" AllowContextMenu="false"> <ClientSideEvents OnAfterInitialize="WebGrid_HideInsertRow" /> <BatchUpdateSettings HighlightChanges="false" PromptUnsavedChanges="false" AllowReviewChanges="false" AllowUndoChanges="false" /> <StatusBarStyle CssClass="general_invisible" /> <TextSettings> <TextItems> <ISWebGrid:WebGridTextItem TextItem="CommonText/NoData" TextValue=" " /> </TextItems> </TextSettings> <FrameStyle CssClass="gridmodal" /> </LayoutSettings> <RootTable ColumnHeaders="Yes" DataKeyField="MessageId"> <Columns> <ISWebGrid:WebGridColumn Caption="Username" DataMember="UserName" Name="UserName" Width="90px" /> <ISWebGrid:WebGridColumn Caption="Name" DataMember="FullName" Name="FullName" Width="150px" /> <ISWebGrid:WebGridColumn Caption="Phone" DataMember="PhoneNumber" Name="PhoneNumber" Width="80px" /> <ISWebGrid:WebGridColumn Caption="Mobile phone" DataMember="MobilePhoneNumber" Name="MobilePhoneNumber" Width="100px" /> <ISWebGrid:WebGridColumn Caption="E-mail" DataMember="EmailAddress" Name="EmailAddress" Width="130px" /> <ISWebGrid:WebGridColumn Caption="Department" DataMember="Department" Name="Department" Width="70px" /> </Columns> </RootTable></ISWebGrid:WebGrid>
Hi again,
Searched the forum and support forum, but can't really understand what you mean by delay/timeout... Is there a specific method for defined?
Along the way searching I tried the following, which unfortunately also had no effect:
for(var i = 0; i < this.grid.RootTable.GetRowsCount(); i++) { grid.RootTable.GetRow(i).Select(); grid.RootTable.GetRow(i).SetDeleted(); } grid.RootTable.UpdateUI(); grid.UpdateState();
This will select the row and use SetDeleted() of the row object instead of Delete(). Also does it call UpdateState() afterwards... The only visual effect is that the last row of this selection is selected. But unfortunatly no rows will be deleted...
Just a thought: does it have something to do with the fact that it isn't possible to delete a pending row change? Because of the batchupdate settings... which, however, are not used, but added to make it work from clientside without server postbacks.
Hope someone can give me the answer that will delete all rows in the WebGrid from clientside... Thanks in advance.
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