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

Turn off EditMode= Batch Programmatically

2 Answers 316 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Megan
Top achievements
Rank 1
Megan asked on 26 Jul 2013, 10:39 PM
I am in love with the new RadGrid EditMode = Batch feature!

There is just two snags I have ran into.  I am switching our grid from EditMode = InPlace to Batch. I have removed the GradEditCommandColumn that I had in place.  Which helped a lot with my columns lining up since I also added in the Scrolling Feature.  :)   
<Telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
       <HeaderStyle Width="40px" />
       <ItemStyle CssClass="MyImageButton" />
</Telerik:GridEditCommandColumn>

If the date is older than a month, we need to lock down the grid so the users can not make any changes to it.  In the past I just hid the Edit and delete button for this.  Now, with Batch I am unsure how to turn off the edit mode?
GridTime.MasterTableView.GetColumn("EditCommandColumn").Visible = false;

Also, The grid is for our Time Management, so the headers say Sunday, Monday, etc with the corresponding dates underneath.  (ie this week the headers read: Sunday 07/21/2013, Monday 07/22/2013, etc). 

The code I have to do this blows up now.  (It errors on the first time in the example below).
GridHeaderItem headerItem = GridTime.MasterTableView.GetItems(GridItemType.Header)[0] as GridHeaderItem;
headerItem["Sunday"].Text = reader.GetValue(0).ToString();
headerItem["Monday"].Text = reader.GetValue(1).ToString();
headerItem["Tuesday"].Text = reader.GetValue(2).ToString();
headerItem["Wednesday"].Text = reader.GetValue(3).ToString();
headerItem["Thursday"].Text = reader.GetValue(4).ToString();
headerItem["Friday"].Text = reader.GetValue(5).ToString();
headerItem["Saturday"].Text = reader.GetValue(6).ToString();

Error message: 

Index was outside the bounds of the array.

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.IndexOutOfRangeException: Index was outside the bounds of the array.

Any help will be much appreciated!

2 Answers, 1 is accepted

Sort by
0
Megan
Top achievements
Rank 1
answered on 27 Jul 2013, 11:25 PM
I have found solutions/workarounds for each issue. 

To "turn off edit mode" and lock down the grid so users cannot edit, I changed EditMode to InPlace since I don't have a Edit button on the Grid that works.  Later I turn it back to Batch when they change the date. 
GridTime.MasterTableView.EditMode = Telerik.Web.UI.GridEditMode.InPlace;
GridTime.MasterTableView.EditMode = Telerik.Web.UI.GridEditMode.Batch;

The issue with renaming the headers, I had to turn the CommandItemDisplay to just Bottom, if it was displayed on the top it would always error.  I think this might be a bug...
CommandItemDisplay="Bottom"


0
Antonio Stoilkov
Telerik team
answered on 31 Jul 2013, 10:21 AM
Hi Megan,

I have tried to replicate the problem with the accessing of the header and the CommandItemDisplay property but to no avail. In order to be able to provide a fix for the issue you could create a sample runnable project showing the unwanted behavior so we could debug it. You could open a new formal ticket or provide a public URL to download the project.

Regards,
Antonio Stoilkov
Telerik
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 the blog feed now.
Tags
Grid
Asked by
Megan
Top achievements
Rank 1
Answers by
Megan
Top achievements
Rank 1
Antonio Stoilkov
Telerik team
Share this question
or