Rank: Newbie Groups: Member
Joined: 8/10/2010 Posts: 1
|
Hi.
I´m using the EO.Web.Grid on Visual Studio but i have a specific need and I can´t find a way to do it.
I have to do a Grid with TextBox columns. But in those columns some of the cells will be editable and some not (the same column could have editables and no editable cells) , and that should be defined in the server side.
I have read the docs and the propierties of the TextBox are defined to work the whole column: you can do a whole column editable or a whole columns not editable, but not the cells individually.
Is there any way to do it? I´d appreciate any help, and I´d give more info if the answer is not clear.
Thanks for all.
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, To have some cells editable and some others not is doable but it must be done on the client side (precisely because there is only one TextBox per column). You can handle the column's ClientSideBeginEdit event and then returns false from that event handler to prevent the cell from entering edit mode. Here is some sample code:
Code: JavaScript
//A global variable that holds a list of "flags" to indicate which
//row should be readonly. The following code assumes the Grid
//has 5 rows, with row 2, 4 and 5 readonly. You can dynamically
//generate this array from the server side
var read_only_rows = [0, 1, 0, 1, 1];
//This function is called everytime the Grid enters edit mode
function on_column_begin_edit(cell)
{
//Get the item index
var row_index = cell.getItem().getIndex();
//Look up in the flag arrays, if it is set then returns false
//indicating that we do not want to enter edit mode
if (read_only_rows[row_index])
return false;
}
Code: HTML/ASPX
<eo:Grid .....>
....
<Columns>
....
<eo:TextBoxColumn ClientSideBeginEdit="on_column_begin_edit"....>
</eo:TextBoxColumn>
....
</Columns>
....
</eo:Grid>
You will need to dynamically generate read_only_rows from your server side code. You can just put a Label in your page and then set the Label's Text to a script block that defines the variable. Thanks!
|