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 !
Thank you for the provided screenshots!
By default all columns' readOnly property is set to False. In order to prevent column editing you need to set it to True and add all columns which property is modified to the ColumnSettings collection. Also since the behavior is enabled through the markup file you need to specify that the settings are related to the columns of the parent grid via the GridView property as follows:
Dim firstCol As EditingColumnSetting = New EditingColumnSetting() firstCol.ColumnKey = "Desc" firstCol.[ReadOnly] = False Dim secondCol As EditingColumnSetting = New EditingColumnSetting() secondCol.ColumnKey = "Price" secondCol.[ReadOnly] = True Dim thirdCol As EditingColumnSetting = New EditingColumnSetting() thirdCol.ColumnKey = "Status" thirdCol.[ReadOnly] = True Me.WebHierarchicalDataGrid1.GridView.Behaviors.EditingCore.Behaviors.CellEditing.ColumnSettings.Add(firstCol) Me.WebHierarchicalDataGrid1.GridView.Behaviors.EditingCore.Behaviors.CellEditing.ColumnSettings.Add(secondCol) Me.WebHierarchicalDataGrid1.GridView.Behaviors.EditingCore.Behaviors.CellEditing.ColumnSettings.Add(thirdCol)
Let me know if I may be of any further assistance.
That's works with me, Thank you!Just I need your to ask another question, I need to make a specific cells read only in an editable column as shown below, I have the editable columns Amount and Rate however I need to make the marked cells read only.
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>