Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
220
WebDataGrid- Handling CheckBoxes
posted

Hi,


I use the below JS method to set a specific cell on a column+ row as readonly/ editable

function WebDataGrid1_CellEditing_EnteringEditMode(grid, eventArgs)
{
var cell = eventArgs.getCell();
var index = cell.get_row().get_index();
var key = cell.get_column().get_key();

if (index == "2" && key == "FIRSTNAME") // ReadOnly
{
eventArgs.set_cancel(true);
}
if(index == "0" && key == "LASTNAME") // Editable
{
eventArgs.set_cancel(false);
}
}

Then i set a value to a specific cell (based upon certain conditions at server side) using the server side logic

grdDataTable.Rows(rowIndex).Items(columnIndex).Text = "Hello"

However, i am facing issues with checkboxes when dealing with these two cases. 

The check box is automatically shown in the grid as the dynamic data bound from the datasource is of type boolean.


1. How to Disable Checkbox(ie Not make it clickable) using the WebDataGrid1_CellEditing_EnteringEditMode JS method,
if there is a checkbox inside the cell where the // ReadOnly condition is satisified.?


2. How to Set CheckBox enabled/disabled using the server side logic that i mentioned above? I tried setting the

grdDataTable.Rows(rowIndex).Items(columnIndex).Value = false/ true (For CheckBox types) but it is throwing an exception


3. If we are to disable editing an entire column using server side logic, How to disable all the checboxes from that column?

Web Page Code: (Please note that i dynamically bind data to the grid)

<ig:WebDataGrid 
ID="grdDataTable" 
runat="server" 
AutoGenerateColumns="true" 
width="100%" 
ClientIDMode="Inherit" 
EnableDataViewState ="true" 
EnableViewState ="true"
HeaderCaptionCssClass="WebDataGridColumnHeader" 
ItemCssClass = "WebDataGridRow"
AltItemCssClass = "WebDataGridAlternating"
OnColumnSorted="grdDataTable_SortColumn"
OnPageIndexChanged="grdDataTable_PageIndexChanged"
OnInitializeRow="grdDataTable_InitializeRow" 
EnableAjax="true" 
OnRowAdding="grdDataTable_RowAdding" 
OnRowUpdating="grdDataTable_RowUpdating">
<Behaviors>
<ig:Selection CellClickAction="Row" CellSelectType="None" RowSelectType="Single" SelectedRowSelectorCssClass="DataGridSelectedRow" >
<SelectionClientEvents />
</ig:Selection>
<ig:Paging PagerAppearance="Bottom" PageSize="100" Enabled="true" />
<ig:Sorting SortingMode="Single" Enabled="true" />
<ig:ColumnResizing Enabled="false" />
<ig:EditingCore Enabled="false" EnableInheritance="false" AutoCRUD="false" BatchUpdating="true">
<EditingClientEvents RowAdding="EditingEvents_RowAdding" />
<Behaviors>
<ig:CellEditing Enabled="true">
<EditModeActions EnableOnActive="true" MouseClick="Single" />
</ig:CellEditing> 
</Behaviors> 
</ig:EditingCore>
<ig:Activation></ig:Activation> 
</Behaviors>
<ClientEvents />
</ig:WebDataGrid>


Thanks,
Aravind

Parents Reply Children
No Data