Hello,
Can you provide me with the way how am I able to make a specific column in the WebHierarchicalDataGrid editable from the code side? Knowing that I am using visual basic in my web forms application.
I have been looking into your question and since by design when the editing feature is enabled all cells are editable an approach I could suggest is to define the columns you do not require to be editable as read-only. This could be achieved by setting the cell editing column settings.
Attached could be found a small sample that demonstrates how such behavior could be achieved through the code behind using VB.NET.
Please test it on your side and let me know if I may be of any further assistance.
Sincerely,Teodosia HristodorovaSoftware Developer
6661.WHDG_readonly_col_VB.zip
Thank you for your answer!Actually still I need your support as I tried your solution as clarified in the below screenshots but all of the column are still enabled for editing, also kindly know that I am binding the columns dynamically in the code, so there are no columns specified in the aspx, and after that I am changing the read only to be true for a specific column as shown in the below screenshot but the column still editable.
The visual basic code:
The aspx:
I appreciate your support !
In order to prevent editing of certain cells in an editable column, my suggestion is to handle the cell editing enter event as follows:
<Behaviors> <ig:EditingCore> <Behaviors> <ig:CellEditing CellEditingClientEvents-EnteringEditMode="enteringEdit"> <ColumnSettings></ColumnSettings> </ig:CellEditing> </Behaviors> </ig:EditingCore> </Behaviors>
In the event handler, you can access the cell and depending on your scenario to prevent entering edit mode by canceling the event:
<script> function enteringEdit(sender, args) { var cell = args.getCell(); var row = cell.get_row(); var col = cell.get_column(); if (col.get_index() === 1 && row.get_index() === 0) { args.set_cancel(true); } } </script> </body>
Let me know if I may be of any further assistance.
Is there another way to make it from visual basic code instead if JavaScript?
Also, the below behavior that you added in the aspx we added it as per your solution from the visual basic code, so we add the CellEditingClientEvents in the visual basic side?
In order to be able to handle some action in code behind this action should cause a postback which would refresh the grid. However, there isn't a postback on editing because this will automatically exit edit mode. Having this in mind, what I could say is that the cell editing events could be handled and canceled only on client-side.
Thank you, That's work!I have another question please, when I change some of the cells I need to press a button to save the changes, but I am not able to get the changes, I still got the old values before the changes done in the grid.
Please note that according to our policy we handle a single issue per case, and since the initial theme is regarding conditionally setting columns as read-only or editable, my suggestion is to create another thread with your new question about saving the changes. This is for better consistency and history tracking.If you require any further assistance on the matter, please let me know.Sincerely,Teodosia HristodorovaSoftware Developer