Welcome Guest Search | Active Topics | Sign In | Register

Detecting Row Change in Grid, and Forcing Postback Options
Steve
Posted: Friday, February 27, 2009 5:03:32 AM
Rank: Newbie
Groups: Member

Joined: 2/27/2009
Posts: 2
Hi,

I have downloaded the EO tools and am having a short evaluation. The grid control seems great, but I am trying to work out the following:

I would like to be able to sydnchonise two grids, but I note that their is no simple postback event fired when a grid row is changed. How can I:

Detect a row change with the appropriate client event, and then in turn fire a server postback
to sync the second grid.

Any help here would be really appreciated. Snippets in VB would be preferred.

Thanks in advance,

Steve
eo_support
Posted: Friday, February 27, 2009 8:53:03 AM
Rank: Administration
Groups: Administration

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

In order to delete an item on the client side, you can call this function:

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

The key for the grid to fire server event is this function:

http://doc.essentialobjects.com/library/1/jsdoc.public.grid.raiseitemcommandevent.aspx

Calling this function on the client side will post back the page and raises server side ItemCommand event. So it should be something like this:

Code: HTML/ASPX
<a href="javascript:deleteAndPostBack(0);">Delete first item!</a>


Code: JavaScript
function deleteAndPostBack(itemIndex)
{
    //Get the Grid object
    var grid = eo_GetObject("Grid1");

    //Delete the item
    grid.deleteItem(itemIndex);

    //Post back and raises ItemCommand event
    //with a unique command name
    grid.raiseItemCommandEvent(itemIndex, "Whatever");
}


You can also use a DeleteCommandColumn in the Grid, so that you do not have to call grid.deleteItem. In that case you will need to handle the Grid's ClientSideOnItemCommand event:

http://doc.essentialobjects.com/library/1/eo.web.grid.clientsideonitemcommand.aspx

The code will be something like this:

Code: HTML/ASPX
<eo:Grid ClientSideOnItemCommand="on_item_command" ....>
.....
</eo:Grid>


Code: JavaScript
function on_item_command(grid, itemIndex, colIndex, commandName)
{
    //Note: Here commandName will always be "Delete", not "Whatever"
    grid.raiseItemCommandEvent(itemIndex, commandName);
}


On the server side you will handle the Grid's ItemCommand event and the
code will be something like this:

Code: Visual Basic.NET
'Check the command name to see if it was
'from our client side code. If it is, then delete
'the same item from Grid2
If e.CommandName = "Whatever" Then
    Grid2.Items.RemoveAt(e.Item.Index)
End If


Hope this helps.

Thanks!
Steve
Posted: Friday, February 27, 2009 6:04:26 PM
Rank: Newbie
Groups: Member

Joined: 2/27/2009
Posts: 2
Thank you; I will try to adapt my code from this.


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.