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

Enable Grid editing from beginning

8 Answers 150 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jack
Top achievements
Rank 1
Jack asked on 10 Jan 2010, 08:59 PM
Hello,

I am unable to find any means to enable client editing of the grid as initial mode.

I wish to have several checkbox colums that can have items checked. As far as I know the table should be in edit mode. But there seems to be no other way than to have a command column, in which the user has to click "UPDATE" or such to enter the edit mode.
What I need is no command column, but just a grid that is in Edit mode from the beginning and has more than one check columns the user can check items in.

Hope you can help me out on this......

Kind regards,

Jack

8 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 11 Jan 2010, 04:41 AM
Hello Jack,

Here's a help document which explains on how to set the grid in EditMode by default:
Default edit mode for grid items on initial load

This should probably help you out!
Princy.
0
Jack
Top achievements
Rank 1
answered on 11 Jan 2010, 07:48 PM
Doesn't work.


It enables my checkboxes.......yes

But: all rows get a selected theme instead of the default.

second. I have a submit button in the page. Once clicked, I wish to traverse the marked items....
However the event handler of the submit button never gets reached!!! (It get reached if I don't include the Prerender of the grid)
Instead it throw a JavaScript error:

Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Specified argument was out of the range of valid values.
Parameter name: index
0
Jack
Top achievements
Rank 1
answered on 11 Jan 2010, 07:54 PM
If I exclude the updatepanel that my grid is in............ then I get a more detailed error:
for your information the version I use is: ASP.NET_AJAX_2009_3_1103


Specified argument was out of the range of valid values.
Parameter name: index

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index]
   System.Web.UI.ControlCollection.get_Item(Int32 index) +8665582
   Telerik.Web.UI.GridTextBoxColumnEditor.LoadControlsFromContainer() +67
   Telerik.Web.UI.GridColumnEditorBase.InitializeFromControl(Control containerControl) +50
   Telerik.Web.UI.GridDataItem.InitializeEditorInCell(IGridEditableColumn column) +157
   Telerik.Web.UI.GridEditManager.GetColumnEditor(IGridEditableColumn column) +175
   Telerik.Web.UI.GridBoundColumn.FillValues(IDictionary newValues, GridEditableItem editableItem) +81
   Telerik.Web.UI.GridEditableItem.ExtractValues(IDictionary newValues) +175
   Telerik.Web.UI.GridTableView.ExtractValuesFromItem(IDictionary newValues, GridEditableItem editedItem) +116
   Telerik.Web.UI.GridItemBuilder.CreateItems(GridGroupingContext group) +1211
   Telerik.Web.UI.GridTableView.CreateItems(IEnumerator enumerator, GridColumn[] columns, ControlCollection controls) +187
   Telerik.Web.UI.GridTableView.CreateControlHierarchy(Boolean useDataSource) +1571
   Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) +785
   System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +158
   System.Web.UI.Control.EnsureChildControls() +87
   Telerik.Web.UI.GridTableViewBase.get_Controls() +33
   System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +24
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221
   System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221
   System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221
   System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221
   System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221
   System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221
   System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221
   System.Web.UI.Page.LoadAllState() +312
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1661
0
Jack
Top achievements
Rank 1
answered on 11 Jan 2010, 07:57 PM
the gridview I use:

 

<telerik:RadGrid ID="RadGridTrackItems" runat="server" AllowSorting="True" AutoGenerateColumns="False"

 

 

GroupingEnabled="False" OnSelectedIndexChanged="RadGridTrackItems_SelectedIndexChanged"

 

 

Skin="Outlook" Height="524px" Width="300px" meta:resourcekey="RadGridTrackItemsResource1"

 

 

GridLines="None" AllowAutomaticUpdates="False" AllowAutomaticInserts="False"

 

 

AllowAutomaticDeletes="False" OnNeedDataSource="RadGridTrackItems_NeedDataSource">

 

 

<MasterTableView AllowMultiColumnSorting="True" GridLines="Both" PageSize="200" AllowCustomSorting="True"

 

 

AllowAutomaticUpdates="False" AllowAutomaticInserts="False" AllowAutomaticDeletes="False"

 

 

Enabled="True" EditMode="InPlace">

 

 

<ExpandCollapseColumn>

 

 

<HeaderStyle Width="20px"></HeaderStyle>

 

 

</ExpandCollapseColumn>

 

 

<RowIndicatorColumn Visible="False">

 

 

</RowIndicatorColumn>

 

 

<PagerStyle Visible="False" />

 

 

</MasterTableView>

 

 

<HeaderStyle HorizontalAlign="Left" VerticalAlign="Top" />

 

 

<ClientSettings AllowColumnsReorder="True">

 

 

<Selecting AllowRowSelect="True" />

 

 

<Scrolling AllowScroll="True" UseStaticHeaders="True" />

 

 

<Resizing AllowColumnResize="True" AllowRowResize="True" EnableRealTimeResize="True"

 

 

ResizeGridOnColumnResize="False" ClipCellContentOnResize="True" />

 

 

</ClientSettings>

 

 

</telerik:RadGrid>

and the cs code to create the columns:

 


 

private void SetupTrackObjectControl()

 

{

 

List<GridColumn> columns = new List<GridColumn>();

 

 

GridCheckBoxColumn chkCol = new GridCheckBoxColumn();

 

chkCol.AllowSorting =

true;

 

chkCol.AllowFiltering =

false;

 

chkCol.Resizable =

true;

 

chkCol.DataField =

"IsDeleted";

 

chkCol.HeaderText = (

string)GetLocalResourceObject("Delete");

 

chkCol.SortExpression =

"IsDeleted";

 

chkCol.UniqueName =

"IsDeleted";

 

chkCol.ReadOnly =

false;

 

 

//this.RadGridTrackItems.AutoGenerateEditColumn = true;

 

 

this.RadGridTrackItems.MasterTableView.Columns.Add(chkCol);

 

 

GridImageColumn imgCol = new GridImageColumn();

 

imgCol.AllowSorting =

true;

 

imgCol.AllowFiltering =

false;

 

imgCol.Resizable =

true;

 

 

//imgCol.ReadOnly = true;

 

imgCol.DataImageUrlFields =

new string[1] { "IconName" };

 

imgCol.DataImageUrlFormatString =

@"..\TrackItems\Icons\{0}.png";

 

imgCol.HeaderText = (

string)GetLocalResourceObject("Icon");

 

imgCol.SortExpression =

"IconName";

 

imgCol.UniqueName =

"IconName";

 

 

this.RadGridTrackItems.MasterTableView.Columns.Add(imgCol);

 

 

GridBoundColumn textCol = new GridBoundColumn();

 

textCol.AllowSorting =

true;

 

textCol.AllowFiltering =

false;

 

textCol.Resizable =

true;

 

textCol.DataField =

"Identity";

 

textCol.ReadOnly =

true;

 

textCol.HeaderText = (

string)GetLocalResourceObject("Identity");

 

textCol.SortExpression =

"Identity";

 

textCol.UniqueName =

"Identity";

 

 

this.RadGridTrackItems.MasterTableView.Columns.Add(textCol);

 

textCol =

new GridBoundColumn();

 

textCol.AllowSorting =

true;

 

textCol.AllowFiltering =

false;

 

textCol.Resizable =

true;

 

textCol.ReadOnly =

true;

 

textCol.DataField =

"DisplayName";

 

textCol.HeaderText = (

string)GetLocalResourceObject("Alias");

 

textCol.SortExpression =

"DisplayName";

 

textCol.UniqueName =

"DisplayName";

 

 

this.RadGridTrackItems.MasterTableView.Columns.Add(textCol);

 

}



data source is set by a custom object:

RadGridTrackItems.DataSource = _contents.Items;

where Items is a list of my items to be displayed



0
Mira
Telerik team
answered on 14 Jan 2010, 04:07 PM
Hi Jack,

I have reviewed your code and it looks correct.

I suggest that you take a look at the following resources showing how functionality similar to the desired by you can be implemented: 
Changing the grid structure dynamically on postback
Programmatic creation
Excel-like RadGrid

If the issues persist, please open a formal support ticket and attach a sample project demonstrating the problem. We will debug it locally and get back to you with our findings.

Sincerely yours,
Mira
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Peter
Top achievements
Rank 1
answered on 02 May 2012, 02:39 AM
I get the same error with custom paging a grid with all rows in edit mode.Any help would be appreciated. 

I have tried using NeedDataSource, but it doesn't seem to work. I dynamically set the controls on Page_Load (post back and not post-back) but without success. It doesn't seem the (IsPostBack) fires before this error... It seems I need to create the columns earlier...  
so what event fires before this error occurs?

-----------------------------
Specified argument was out of the range of valid values.
Parameter name: index 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 


Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index

Stack Trace: 

[ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index]
   System.Web.UI.ControlCollection.get_Item(Int32 index) +8820194
   Telerik.Web.UI.GridTextBoxColumnEditor.LoadControlsFromContainer() +70
   Telerik.Web.UI.GridColumnEditorBase.InitializeFromControl(Control containerControl) +50
   Telerik.Web.UI.GridDataItem.InitializeEditorInCell(IGridEditableColumn column) +157
   Telerik.Web.UI.GridEditManager.GetColumnEditor(IGridEditableColumn column) +175
   Telerik.Web.UI.GridBoundColumn.FillValues(IDictionary newValues, GridEditableItem editableItem) +82
   Telerik.Web.UI.GridEditableItem.ExtractValues(IDictionary newValues) +164
   Telerik.Web.UI.GridTableView.ExtractValuesFromItem(IDictionary newValues, GridEditableItem editedItem) +115
   Telerik.Web.UI.GridItemBuilder.CreateItems(GridGroupingContext group) +1129
   Telerik.Web.UI.GridTableView.CreateItems(IEnumerator enumerator, GridColumn[] columns, ControlCollection controls) +193
   Telerik.Web.UI.GridTableView.CreateControlHierarchy(Boolean useDataSource) +2170
   Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) +832
   System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +161
   System.Web.UI.Control.EnsureChildControls() +102
   Telerik.Web.UI.GridTableViewBase.get_Controls() +33
   System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +24
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +225
   System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +148
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +225
   System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +148
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +225
   System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +148
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +225
   System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +148
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +225
   System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +148
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +225
   System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +148
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +225
   System.Web.UI.Page.LoadAllState() +312
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +747
0
Peter
Top achievements
Rank 1
answered on 02 May 2012, 02:41 AM
Ok, this is my error: http://www.telerik.com/community/forums/aspnet/grid/editing-when-programmatic-creation.aspx  Adding the column first before setting properties. Very strange.

Now I still need to solve the problem of the Grid not remaining in edit mode after paging.

0
Andrey
Telerik team
answered on 07 May 2012, 07:55 AM
Hi,

As this article says when you will add columns to the specified collections depends on which events you are doing it. If it is on Page_Load you should add the column first, otherwise no ViewState will be persisted. If it is on Page_Init you should add the column after you have set all of its properties.

About your other question you have several options that are described in this help topic.

Give these suggestion a try and check whether this solves your issue.
All the best,
Andrey
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Jack
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Jack
Top achievements
Rank 1
Mira
Telerik team
Peter
Top achievements
Rank 1
Andrey
Telerik team
Share this question
or