This is a migrated thread and some comments may be shown as answers.

Interactive Grid

1 Answer 110 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nathan J Pledger
Top achievements
Rank 2
Nathan J Pledger asked on 15 Jun 2009, 10:55 AM
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?

1 Answer, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 17 Jun 2009, 10:48 AM
Hi Nathan,

The checkbox column is not editable in standard mode.
One possible option in this case would be to have all items in edit mode. Then, you can check the items as required and update all the items in one go.
I hope this suggestion helps.

Best wishes,
Yavor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Nathan J Pledger
Top achievements
Rank 2
Answers by
Yavor
Telerik team
Share this question
or