Welcome Guest Search | Active Topics | Sign In | Register

clearing/resetting grid Options
Steve G
Posted: Thursday, August 14, 2014 2:27:18 PM
Rank: Newbie
Groups: Member

Joined: 2/11/2014
Posts: 7
My grid is bound to a datasource, created with a SQL statement that uses data from a text box.
If the user makes a change to the text box, I would like to clear the grid of all rows, using a client side java function. Any suggestions on how to do this?



eo_support
Posted: Thursday, August 14, 2014 4:19:46 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
Hi,

The easiest way to do this is through server side code:

Code: C#
Grid1.Items.Clear();


You can put the Grid inside a CallbackPanel if you don't want to reload the whole page. There is no direct equivalent for Items.Clear on client side. If you must delete all items on client side, you can call this method in a loop:

http://www.essentialobjects.com/doc/1/jsdoc.public.grid.deleteitem.aspx

It will be something like this:

Code: JavaScript
//Get the client side Grid object
var grid = eo_GetObject("Grid1");

//Delete all items
for (var i = 0; i < grid.getItemCount(); i++)
   grid.deleteItem(i);


Note that when you delete a row on the client side, it does not delete the item from the Items collection, when the page is posted back the Items collection will still contain all the items. However the "deleted" item has this property set to true:

http://www.essentialobjects.com/doc/1/eo.web.griditem.deleted.aspx

This allows your server side code to examine which item has been deleted and act accordingly.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.