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

[Solved] Open RadGrid in Editmode

14 Answers 628 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Markus
Top achievements
Rank 2
Markus asked on 04 Jun 2008, 12:26 PM
Hello!
I have a very simple and common requirement:
The Radgrid should be started entirely in editmode="inPlace".
Unfortunately I'v found nothing to achieve this. Something like IsEditable="true" in the aspx page would be great.
Thx in advance

14 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 05 Jun 2008, 05:56 AM
Hi Markus,

Check out the following link.
Put all items in edit mode without additional rebind

Shinu.
0
Markus
Top achievements
Rank 2
answered on 05 Jun 2008, 07:38 AM
hi!
thx for your hint, the approach works well an fits to my needs.

There is one little obstacle left: If I try to sort the grid, the rows are not in editmode anymore.

Is there something I can do about it?
0
Sebastian
Telerik team
answered on 05 Jun 2008, 08:01 AM
Hi Markus,

Can you please confirm that the code inside the PageLoad handler gets executed when sorting action occurs and you have not wrapped it inside !IsPostBack conditional block? You may also try the alternative to switch the items in edit mode and rebind the grid as shown in this topic.

Best regards,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Markus
Top achievements
Rank 2
answered on 05 Jun 2008, 08:17 AM
I actually switch to editmode (all rows) by a button click. However, after usual postbacks the rows remain in editmode. After sorting the rows switch to viewmode.
I saw that after clicking the sort column, the grid is rebound. Is this the problem? My "switch to editmode button" code looks like this:
{
SwitchRowsToEditMode();
grid.Rebind();
}

So, here it seems to be no problem to rebind the grid... Actually it is necessary to do so
kind regards

0
Sebastian
Telerik team
answered on 06 Jun 2008, 12:27 PM
Hi Markus,

At this point I suggest you isolate a runnable version of your project, demonstrating the erroneous behavior, and send it attached to a formal support ticket. I will test it on my end and will get back to you with my findings.

Best regards,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Markus
Top achievements
Rank 2
answered on 06 Jun 2008, 12:57 PM
ok, i'll do that in the near future.

Can you tell me how I can ensure that the detailtables are opened in edit mode as well ?
0
Sebastian
Telerik team
answered on 06 Jun 2008, 01:03 PM
Hello Markus,

You can traverse the items in the detail tables either recursively or using the Items collection of the grid instance to accomplish this task. Review this topic from the online documentation for more details:

http://www.telerik.com/help/aspnet-ajax/grdtraversingdetailtablesitemsingrid.html

Best regards,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Markus
Top achievements
Rank 2
answered on 06 Jun 2008, 01:09 PM
I know that, but I can't find a property where I can put the detailtable in editmode.
Actually I'd like to figure out these things by myself, but I can't find a good documentation for all the radgrid objects.
Is there a api reference that documents all events, methods and properties ?


0
Sebastian
Telerik team
answered on 09 Jun 2008, 06:20 AM
Hello Markus,

You can set the Edit property for each of the items from the detail table to true and invoke the Rebind() method for the corresponding child table to switch it in edit mode (the same approach presented for the master table from the help article linked in one of my previous replies).

To familiarize with the client/server API of RadGrid review the help articles linked below:

http://www.telerik.com/help/aspnet-ajax/grdgettingfamiliarwithserverapi.html
http://www.telerik.com/help/aspnet-ajax/grdgettingfamiliarwithclientapi.html

Regards,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Markus
Top achievements
Rank 2
answered on 09 Jun 2008, 08:09 AM
Hello Stephen,

thx for your help, I really appreciate your patience.

I already know the links your provided, but still I think that these helppages should go into more detail. A page that explains every single method and every single property would be great.

Anyway, back to my problem :-) :
I have a button on the page that switches to edit mode:

 protected void btnEdit_Click(object sender, EventArgs e)
        {
            PutGridInEditMode();
            rgActionItems.Rebind(); //RadGrid
        }

        private void PutGridInEditMode()
        {
            int maxIndex = rgActionItems.Items.Count;
            for (int i = 0; i < maxIndex; i++)
            {
                rgActionItems.EditIndexes.Add(i);
            }
        }

Now, as the page is in editmode, I want to open every detailtable in editmode as well:

protected void rgActionItems_DetailTableDatabind(object sender, GridDetailTableDataBindEventArgs e)
        {
            ICollection<IKindActivity> coll = (ICollection<IKindActivity>)rgActionItems.DataSource;
            GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;
            string mnId = dataItem.GetDataKeyValue("Id").ToString();
           
            foreach (IParent parent in coll)
            {
                if (parent.Id.Equals(mnId))
                {
                    e.DetailTableView.DataSource = parent.childElements;
                }
            }
        }

        protected void rgActionItems_TablePreRender(object sender, EventArgs e)
        {
            foreach(GridDataItem gdi in rgActionItems.MasterTableView.Items)
            {
                if(gdi.ChildItem.NestedTableViews.Length > 0)
                {
                    foreach (GridTableView view in gdi.ChildItem.NestedTableViews)
                    {
                        if (rgActionItems.EditIndexes.Count > 0)
                        {
                            foreach (GridDataItem gdi2 in view.Items)
                            {
                                gdi2.Edit = true;
                            }
                            //view.Rebind() throws NullPointerException
                        }
                    }
                }
            }

        }

The Items appear yellow, which should indicate that they are in editmode, but I can't edit the detailtables, only the parents.
If I remove gdi2.Edit = true, the detailtables are white, so gdi2.Edit does at least something, but not what it should do.
Please also see that xxx.Rebind() always throws a nullpointer exception, allthough the invoked methods (NeedDataSource etc.) don't throw any exception.
I also tried adding an EditButtonColumn, this approach puts the cells in editmode as expected - but this approach isn't appreciated by our customer.

Thx in advance for your help and kind regards
0
Markus
Top achievements
Rank 2
answered on 09 Jun 2008, 02:45 PM
Alright, finally I "solved" this issue:

I set up a sample project that should demonstrate the problem, but everything worked out well there. I realized another bug (setting EditMode to InPlace in the codebehind class which avoids further detailtable loading) but the main thing worked well.
I then added the property "EditMode="InPlace"" in my project and suddenly everything worked in my solution too.
If I remove the "EditMode" property in the sampleproject, the project is still working. I hope I can reproduce the error somehow, b/c I really think this behaviour is kind of weird.

Should I open a support ticket that demonstrates this EditMode thing? I actually didn't investigate this behaviour any further b/c I don't need it in my project. Perhaps these problems are connected somehow.
Kind regards
0
Sebastian
Telerik team
answered on 10 Jun 2008, 08:01 AM
Hello Markus,

Switching the EditMode property value or explicitly setting this property should not affect the behavior of RadGrid. If you are able to isolate a sample application which illustrates the abnormality, feel free to submit it via our support ticketing system. I will examine your complete code logic and will get back to you with my findings.

Best regards,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Markus
Top achievements
Rank 2
answered on 10 Jun 2008, 08:15 AM
Hi Stephen,

I opened a support ticket today (143160). I also refer to another issue, but the sample project is the same.

Kind regards
0
Sebastian
Telerik team
answered on 11 Jun 2008, 08:42 AM
Hi Markus,

Thank you for the example. I will review it and will reply to you in the support ticket you opened with regards to this subject.

Kind regards,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
Markus
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Markus
Top achievements
Rank 2
Sebastian
Telerik team
Share this question
or