Welcome Guest Search | Active Topics | Sign In | Register

Eo:Grid How to disable a row in eo:Grid Options
uday
Posted: Friday, July 10, 2009 4:42:22 PM
Rank: Member
Groups: Member

Joined: 7/10/2009
Posts: 10
Hi,

I am using eo:Grid,I want to disable a particular row depending on the condition from data base.
i want the particular row to be visible in the grid but the User should not able to do any right click operations .
also i am using ContextMenu ,user should not see this MenuItem if the row is disabled.

Thanks a lot
Uday
eo_support
Posted: Friday, July 10, 2009 5:27:50 PM
Rank: Administration
Groups: Administration

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

There is no way to directly disable an item in the Grid. However you can code to make it "looks" disabled. This includes:

1. Assign a different StyleSetID to those GridItems so that they visually look different. See here for more information about how to customize styles:

http://doc.essentialobjects.com/library/1/grid/styling.aspx

If you populate it from database, you can set the Grid's StyleSetIDField:

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

2. Add an additional GridColumn and set this column's Visible to false. You will use this field to store values indicating whether the GridItem is enabled;

3. If you allow edit on the Grid, handle the Grid's ClientSideBeforeEditItem (when FullRowMode is set to true) or the Grid columns' ClientSideBeforeEdit event and return false from your handler to disable editing. It will be something like this:

Code: HTML/ASPX
<eo:Grid ClientSideBeforeEditItem="before_edit_handler" ....>
....
</eo:Grid>


Code: JavaScript
function before_edit_handler(gridItem, save)
{
    //This code assumes the first column is the hidden
    //column that stores value indicating whether the 
    //item should be disabled. Also it assumes value "1"
    //means the item is disabled
    if (gridItem.getCell(0).getValue() == "1")
       return false;
}


3. If you use ContextMenu, change your code to check whether the item is disabled. For example:
Code: JavaScript
function ShowContextMenu(e, grid, item, cell)
{
    //Return directly if the item is disabled.
    //NOTE: THE CODE RETURN true HERE. THIS IS
    //NOT A TYPO. If you return false the default
    //browser context menu will be shown
    if (item.getCell(0).getValue() == "1")
       return true;

    ....code to show context menu
}


Hope this helps.

Thanks!
uday
Posted: Friday, July 10, 2009 6:19:27 PM
Rank: Member
Groups: Member

Joined: 7/10/2009
Posts: 10
Hi,

Thanks a lot for your quick response.

Thanks
Uday


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.