Hi,
I would like a grid to have a checkbox column which is readily "checkable" by the user and a fixed (bound) textual column to the right of this column. Much like a CheckBoxLst control.
I have the following RadGrid:
<telerik:RadGrid ID="radGridGroups" runat="server" |
AllowCustomPaging="false" |
AllowAutomaticDeletes="false" |
AllowAutomaticInserts="false" |
AllowAutomaticUpdates="true" |
AllowFilteringByColumn="false" |
AllowMultiRowEdit="true" |
AllowMultiRowSelection="false" |
AllowPaging="false" |
AllowSorting="false" |
AutoGenerateColumns="false" |
AutoGenerateDeleteColumn="false" |
AutoGenerateEditColumn="false" |
EnableHeaderContextMenu="false" |
GroupingEnabled="false" |
Height="200" |
ShowStatusBar="false" |
ShowFooter="false" |
ShowGroupPanel="false" |
ShowHeader="false" |
Width="340" |
> |
<ClientSettings AllowColumnHide="false" AllowColumnsReorder="false" AllowRowHide="false" AllowRowsDragDrop="false" EnableAlternatingItems="false" EnablePostBackOnRowClick="false" EnableRowHoverStyle="false"> |
<Resizing AllowColumnResize="false" AllowRowResize="false" /> |
<Scrolling AllowScroll="true" EnableVirtualScrollPaging="true" /> |
<Selecting AllowRowSelect="false" EnableDragToSelectRows="false" /> |
</ClientSettings> |
<MasterTableView GridLines="None" NoMasterRecordsText="There are no Groups defined" DataKeyNames="DataGroupID"> |
<Columns> |
<telerik:GridCheckBoxColumn DataField="IsEnabled" DataType="System.Boolean" HeaderText="In Group" Resizable="false" Reorderable="false" UniqueName="IsEnabled" ReadOnly="false" > |
<ItemStyle Width="20" /> |
</telerik:GridCheckBoxColumn> |
<telerik:GridBoundColumn DataField="DataGroupName" DataType="System.String" HeaderText="Group Name" Resizable="false" Reorderable="false" ReadOnly="true" UniqueName="DataGroupName"> |
<ItemStyle Width="320" /> |
</telerik:GridBoundColumn> |
</Columns> |
<RowIndicatorColumn Display="false" /> |
</MasterTableView> |
</telerik:RadGrid> |
I bind this using the LINQ:
private void PopulateDataGroupsGrid(bool rebind) |
{ |
var query = from dg in _dataGroups |
join dgi in _originalDataGroupItems on dg.ID equals dgi.ParentDataGroup.ID into sr |
from x in sr.DefaultIfEmpty() |
select new { DataGroupID=dg.ID, IsEnabled = x != null, DataGroupName=dg.Name }; |
radGridGroups.DataSource = query; |
if (rebind) radGridGroups.DataBind(); |
} |
Which is called by the NeedDataSource event handler:
void radGridGroups_NeedDataSource(object source, GridNeedDataSourceEventArgs e) |
{ |
PopulateDataGroupsGrid(false); |
} |
The problem is that this produces a static grid. I can't tick/untick the items in the grid. I don't want to use a Row Selection mechanism, and I will need to add further columns in the future.
I would dearly like to have the users just "tick"/"untick" as they see fit, hit the "Save" button on my form and for me to then apply the changes to the DB.
How can I best achieve this?