Hi,
I tried to enable/disable a webgrid, but I don't have good results.
I used:
uwg.DisplayLayout.ReadOnly = Infragistics.WebUI.UltraWebGrid.ReadOnly.LevelZero;
Disabled, perfect, but, How I enable this again?
uwg.DisplayLayout.ReadOnly = Infragistics.WebUI.UltraWebGrid.ReadOnly.NotSet;
I need to know how to enable/disable a webgrid using C# and JavaScript.
Someone?
Thanks.
You won't be able to use the ReadOnly property with JavaScript. Setting this property causes the grid to render without most or all of its JavaScript capabilities.
If you wanted to do this in JavaScript, I would use a different approach. Set a page-level varaible (or possibly a hidden field) with a default value of 0. In response to whatever event you want to disable the whole grid, set it to 1. At that point, you should be able to cancel any attempt to edit or add to the grid by checking the value of this flag.
For instance, the following JavaScript code will prevent edits to existing cells in the grid whenever the flag "disableGrid" (which I assume is set as a page-level variable) is set to 1:
function ultraWebGrid1_BeforeEnterEditModeHandler(gridName, cellId){ if (disableGrid == 1) return true; // This cancels the BeforeEnterEditMode event}
Other WebGrid client-side events can be canceled in a similar fashion.
Thanks Vince,
How about C#? How to do it?
Thanks again!
For C#, setting the ReadOnly back to NotSet should, to my knowledge, make the WebGrid again editable when the page is next rendered.