Welcome Guest Search | Active Topics | Sign In | Register

Grid - Excel Style on edit item Options
Mona
Posted: Wednesday, July 22, 2009 6:39:53 PM
Rank: Advanced Member
Groups: Member

Joined: 5/15/2009
Posts: 33
Is it possible to disable the editing mode on some rows in the grid based on certain criteria like based on a column value? How could this be done?

Thanks,
Mona
eo_support
Posted: Wednesday, July 22, 2009 8:22:02 PM
Rank: Administration
Groups: Administration

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

You can do this by handling the Grid's ClientSideBeforeEditItem event (when FullRowMode is true) or the GridColumn's ClientSideBeginEdit event (when FullRowMode is false).

The following code demonstrates how to cancel the edit when FullRowMode is true. It does not allows you to enter edit mode if the value in the first cell of the row is a number that's less than 10.

Code: HTML/ASPX
<eo:Grid runat="server" ID="Grid1" 
    ClientSideBeforeEditItem="before_edit_item" .....>
    ....
</eo:Grid>


Code: JavaScript
function before_edit_item(gridItem, save)
{
    //This handler returns false to cancel the edit
    //if value in the first cell is less than 10
    if (parseInt(gridItem.getCell(0).getValue()) < 10)
        return false;
}


The following code demonstrates how to cancel the edit when FullRowMode is false. It does not allow you to enter edit mode if the cell to be editted contains text "---".

Code: HTML/ASPX
<eo:Grid runat="server" ID="Grid1" ....>
    .....
    <Columns>
        <eo:TextBoxColumn ClientSideBeginEdit="column_begin_edit">
        </eo:TextBoxColumn>
    </Columns>
</eo:Grid>


Code: JavaScript
function column_begin_edit(cell)
{
    //Return false to cancel the edit if the cell value is "---"
    if (cell.getValue() == "---")
        return false;
}


Hope this helps.

Thanks!


Mona
Posted: Thursday, July 23, 2009 2:38:07 PM
Rank: Advanced Member
Groups: Member

Joined: 5/15/2009
Posts: 33
Great. Thank you for the examples posted.


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.