Hi,
my grid has a Delete Column & an Edit Column..
At runtime, i enabled=False & text="" these columns for certain rows within the grid_ItemDataBound.
This works great, except, when i drag a column to use as group (still fine), and then minimize one of the groups, all the column buttons are visible.
If i then refresh the grid, my enabled/disabled columns are how i want again.
It seems to ignore the grid_ItemDataBound for the group minimize / maximize.
Any ideas please ?
Mark
my grid has a Delete Column & an Edit Column..
At runtime, i enabled=False & text="" these columns for certain rows within the grid_ItemDataBound.
This works great, except, when i drag a column to use as group (still fine), and then minimize one of the groups, all the column buttons are visible.
If i then refresh the grid, my enabled/disabled columns are how i want again.
It seems to ignore the grid_ItemDataBound for the group minimize / maximize.
Any ideas please ?
Mark
4 Answers, 1 is accepted
0
Mark
Top achievements
Rank 1
answered on 08 Oct 2008, 07:59 AM
Any ideas please?
Mark
Mark
0
Hi Mark,
By default the grid will not be bound on groups expand/collapse and that is why ItemDataBound is not raised. You can use ItemCreated to achieve the same instead of ItemDataBound. If you want to check some field value in this event you can use DataKeyNames/DataKeyValues:
if(e.Item is GridDataItem)
{
object value = ((GridDataItem)e.Item).GetDataKeyValue("YourKeyName");
...
}
Sincerely yours,
Vlad
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
By default the grid will not be bound on groups expand/collapse and that is why ItemDataBound is not raised. You can use ItemCreated to achieve the same instead of ItemDataBound. If you want to check some field value in this event you can use DataKeyNames/DataKeyValues:
if(e.Item is GridDataItem)
{
object value = ((GridDataItem)e.Item).GetDataKeyValue("YourKeyName");
...
}
Sincerely yours,
Vlad
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mark
Top achievements
Rank 1
answered on 08 Oct 2008, 08:32 AM
Hi,
I am using
If TypeOf e.Item is GridDataItem Then...
dim Item as GridDataItem = e.Item
within ItemDataBound.
But i cant do this within ItemCreated as the typeof e.item is GridCommandItem for expand/collapse., so dim item as GridDataItem = e.Item fails.
?
Mark
I am using
If TypeOf e.Item is GridDataItem Then...
dim Item as GridDataItem = e.Item
within ItemDataBound.
But i cant do this within ItemCreated as the typeof e.item is GridCommandItem for expand/collapse., so dim item as GridDataItem = e.Item fails.
?
Mark
0
Hi Mark,
I think that what my colleague Vlad meant was to add the column which determines whether the button in the edit/delete column will be disabled or not to the DataKeyNames collection fo the grid and then use the GetDataKeyValue(columnName) method inside the ItemCreated handler to set the state of the buttons.
For example:
I hope these directions are helpful.
Best regards,
Stephen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
I think that what my colleague Vlad meant was to add the column which determines whether the button in the edit/delete column will be disabled or not to the DataKeyNames collection fo the grid and then use the GetDataKeyValue(columnName) method inside the ItemCreated handler to set the state of the buttons.
For example:
private void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e) |
{ |
if(e.Item is GridDataItem) |
{ |
GridDataItem dataItem = e.Item as GridDataItem; |
//assuming that <MyKeyValueColumn> is the name of the column added to the DataKeyNames collection of the master table. This column values specify whether the delete button will be disabled or not |
String keyValue = dataItem.GetDataKeyValue("<MyKeyValueColumn>").ToString(); |
//provided that the unique name of the delete column is 'DeleteColumn' |
if(keyValue == "<enabled_value>") |
{ |
(dataItem["DeleteColumn"].Controls[0] as LinkButton).Enabled = true; |
} |
else |
{ |
(dataItem["DeleteColumn"].Controls[0] as LinkButton).Enabled= false; |
} |
} |
} |
I hope these directions are helpful.
Best regards,
Stephen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.