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

Grid with all rows in edit mode at all times

18 Answers 1281 Views
Grid
This is a migrated thread and some comments may be shown as answers.
abonfig
Top achievements
Rank 1
abonfig asked on 30 Dec 2009, 04:38 PM
Is it feasible to have a RadGrid that basically always has every row in edit/insert mode at all times, in essence removing the need of a method of selecting a row for editing?  If so, is there a demo that demonstrates this?

Thanks,
Aaron

18 Answers, 1 is accepted

Sort by
0
Schlurk
Top achievements
Rank 2
answered on 30 Dec 2009, 07:16 PM
There are a few ways to do this. Either you use the following piece of code:

protected void MyGrid_ItemCreated(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridEditableItem) 
        { 
            (e.Item as GridEditableItem).Edit = true
        } 
    } 
 

Which sets up the items to be editable through the ItemCreated event, or you do the following:
   protected void Page_Load(object  sender, EventArgs e) 
   { 
        for (int i = 0; i < RadGrid1.PageSize; i++) 
       { 
           RadGrid1.EditIndexes.Add(i); 
       } 
   } 

Which sets it up in the PreRender event.
0
Princy
Top achievements
Rank 2
answered on 31 Dec 2009, 05:19 AM
Hi Abonfig,

You can also refer to the following help document which demonstrtaes on how to force the grid items in edit mode when the grid displays initially on the page:
Default edit mode for grid items on initial load

Happy New Year!
-Princy.
0
abonfig
Top achievements
Rank 1
answered on 04 Jan 2010, 05:02 PM
Hello,

Thanks for the suggestions.  The "ItemCreated" method, while it runs without errors, does not seem to do anything.  The grid rows do not appear in "edit" mode.

Using the "Default edit mode for grid items on initial load" method, I get an error when I try to run the grid's rebind event:
Specified argument was out of the range of valid values.
Parameter name: index


Any thoughts as to what could be happening here?

Thanks,
Aaron
0
abonfig
Top achievements
Rank 1
answered on 04 Jan 2010, 07:53 PM
Additional information:  it looks like the rows are being "selected" as if I am clicking on them, but they are still read-only and I am expecting to see the columns with textboxes, checkboxes, etc.  Perhaps I am missing a configuration setting?

Thanks,
Aaron
0
Schlurk
Top achievements
Rank 2
answered on 04 Jan 2010, 08:39 PM
Just to make sure: have you defined an edit form or an in-line edit form for which to use for the editing? This is what is displayed when a row is in edit-mode, and it would fall under the configuration area!
0
abonfig
Top achievements
Rank 1
answered on 04 Jan 2010, 08:50 PM
I am currently setup for "InPlace" editing.
0
abonfig
Top achievements
Rank 1
answered on 06 Jan 2010, 04:32 PM
Just to clarify, are you saying I need to do some additional setup in the grid's configuration when using InPlace editing?  I've used InPlace edit mode in other grids and have never had to declare any kind of "in-line edit form".  Is there documentation/examples on this?

Also don't know if it makes a difference but I am using the NeedDataSource event to populate the grid.

Thanks,
Aaron
0
Carl
Telerik team
answered on 06 Jan 2010, 04:47 PM
Hello Aaron,

Attached to this post you will find a sample which has a RadGrid (connected to a SqlDataSource) which has in-place editing and all its rows are in edit-mode when the page is loaded. Something to note is that you have to set the AllowMultiRowEdit property to true otherwise you cannot have several rows editable at once. Take note that the example uses the PreRender approach discussed in the previously linked documentation article.

Best wishes,
Carl
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
Schlurk
Top achievements
Rank 2
answered on 06 Jan 2010, 04:49 PM
Edit: Carl beat me to it!

Anyways, I don't think that the NeedDataSource event should make a difference, since these events are all fired no matter what way the data is bound.
0
abonfig
Top achievements
Rank 1
answered on 06 Jan 2010, 05:02 PM
Carl - Thanks, but I did try that method, and as I mentioned in a previous post I got the following error on the line of code that calls the Rebind() method:
Specified argument was out of the range of valid values.
Parameter name: index


I have ensured that I have AllowMultiRowEdit property set to true.  One interesting thing I noticed...if I declare an <EditItemTemplate> markup in the grid declaration with a background color of red, when the page renders, each row in the grid has a thin red line underneath it.  This seems to tell me that it is partially working, but I am missing something to get the textboxes to appear for in-line editing.

If it helps, here is the grid code:

<telerik:RadGrid ID="rgInvoiceCharges" runat="server"   
            Width="700px" AllowMultiRowEdit="true" AutoGenerateColumns="false" 
            OnNeedDataSource="rgInvoiceCharges_NeedDataSource"
            onitemdatabound="rgInvoiceCharges_ItemDataBound" OnItemCreated="rgInvoiceCharges_ItemCreated" 
            OnPreRender="rgInvoiceCharges_PreRender" >  
            <MasterTableView CommandItemDisplay="Top" AutoGenerateColumns="false" EditMode="InPlace" ShowFooter="true">  
                <NoRecordsTemplate></NoRecordsTemplate>  
                <CommandItemTemplate></CommandItemTemplate>  
                <FooterStyle HorizontalAlign="left" />  
                <Columns>  
                      
                    <telerik:GridBoundColumn UniqueName="GridKey" DataField="GridKey" HeaderText="Grid Key" Visible="False">  
                    </telerik:GridBoundColumn>  
                      
                    <telerik:GridBoundColumn UniqueName="PKey" DataField="PKey" HeaderText="JOBRATE.JR_PKEY" Visible="False">  
                    </telerik:GridBoundColumn>  
                      
                    <telerik:GridBoundColumn UniqueName="RateRulePKey" DataField="Rule.PKey" HeaderText="RateRule PKey" Visible="False">  
                    </telerik:GridBoundColumn>  
                      
                    <telerik:GridBoundColumn DataField="Rule.InternalName" HeaderText="Charge Description" UniqueName="ChargeDescription">  
                        <HeaderStyle Width="300px" HorizontalAlign="Center" />  
                    </telerik:GridBoundColumn>  
                      
                    <telerik:GridBoundColumn DataField="Description" HeaderText="Type" UniqueName="ChargeType">  
                        <HeaderStyle Width="75px" HorizontalAlign="Center" VerticalAlign="Bottom" />  
                    </telerik:GridBoundColumn>                
                          
                    <telerik:GridBoundColumn DataField="Quantity" HeaderText="Qty" UniqueName="Quantity">  
                        <HeaderStyle Width="75px" HorizontalAlign="Center" VerticalAlign="Bottom" />  
                    </telerik:GridBoundColumn>  
                      
                    <telerik:GridBoundColumn DataField="Rate" HeaderText="Per Quantity Rate" UniqueName="PerQtyRate">  
                        <HeaderStyle Width="125px" HorizontalAlign="Center" VerticalAlign="Bottom" />  
                    </telerik:GridBoundColumn>  
                      
                    <telerik:GridBoundColumn DataField="TotalRate" HeaderText="TTL Rate" UniqueName="TotalRate">  
                        <HeaderStyle Width="75px" HorizontalAlign="Center" VerticalAlign="Bottom" />  
                    </telerik:GridBoundColumn>  
                      
                    <telerik:GridCheckBoxColumn DataField="Over" HeaderText="Over" UniqueName="Override">  
                        <HeaderStyle Width="50px" HorizontalAlign="Center" VerticalAlign="Bottom" />  
                    </telerik:GridCheckBoxColumn>  
                     
                </Columns>  
 
            </MasterTableView>  
        </telerik:RadGrid> 
0
Carl
Telerik team
answered on 07 Jan 2010, 09:21 AM
Hello Aaron,

I tested your Grid setup and was unable to reproduce the error you were receiving. I managed to get a Grid with all rows already in edit mode.

Would you be able to package your implementation into a working sample (which displays the issue) and submit it in a support ticket?

Sincerely yours,
Carl
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
Neil N
Top achievements
Rank 2
Iron
Iron
Veteran
answered on 05 Mar 2010, 11:18 PM
I got the demo working and made a few changes to suit my particular needs but how do I get the fields in all rows to stay editable when grid paging is on? They revert back to the default behaviour when I move to another page.
0
Princy
Top achievements
Rank 2
answered on 08 Mar 2010, 12:18 PM
Hi,

You can set all the rows to always be in edit in the PreRender event  as shown below:

C#
  protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
            foreach (GridDataItem dataItem in RadGrid1.Items) 
            { 
                dataItem.Edit = true
            } 
            RadGrid1.Rebind(); 
    } 


Hope this helps.

Thanks
Princy
0
Mattia
Top achievements
Rank 2
answered on 19 Sep 2014, 04:01 PM
Hi Princy,
I'm following your example and also your tutorial
http://www.telerik.com/help/aspnet-ajax/grid-put-all-items-in-edit-mode-no-additional-rebind.html
but is not working.
As you can see from the screenshot only the last record is in editmode

<telerik:RadGrid runat="server" ID="Grid1" OnPreRender="Grid_PreRender" OnNeedDataSource="NeedDataSource">
    <MasterTableView AutoGenerateColumns="false" EditMode="InPlace" CommandItemDisplay="Top"
         DataKeyNames="Spnid"
         ShowGroupFooter="true" >
         <Columns>
              
             <telerik:GridBoundColumn DataField="Spncod" HeaderText="Codice" UniqueName="Spncod">
             </telerik:GridBoundColumn>
             <telerik:GridBoundColumn DataField="TipoSoglia" HeaderText="Tipo Soglia" UniqueName="TipoSoglia">
             </telerik:GridBoundColumn>
             <telerik:GridBoundColumn DataField="Count" HeaderText="Conteggio" UniqueName="Count" FooterText="Sum Count : " Aggregate="Sum">
             </telerik:GridBoundColumn>
               <telerik:GridCalculatedColumn HeaderText="Count+Count*3" UniqueName="Count3" DataType="System.Double"
                 DataFields="Count, Count" Expression="{0}+{1}*3" FooterText="Count+Count*3 : "
                 Aggregate="Sum">
             </telerik:GridCalculatedColumn>
             <telerik:GridButtonColumn ConfirmText="Delete it?" ConfirmDialogType="RadWindow"
                 ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                 UniqueName="DeleteColumn">
                 <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton"></ItemStyle>
             </telerik:GridButtonColumn>
         </Columns>       
     </MasterTableView>
  
 </telerik:RadGrid>


protected void Page_Load(object sender, EventArgs e)
    {
        
         
    }
 
    protected void NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        List<MyList> dataList1 = Data1.LoadData();
        Grid1.DataSource = dataList1;
    }
 
 
 
    protected void Grid_PreRender(object sender, System.EventArgs e)
    {
        foreach (GridDataItem dataItem in Grid1.Items)
        {
            dataItem.Edit = true;
        }
       Grid1.Rebind();
    }

I'm using the last version of telerik

Thanks
0
Konstantin Dikov
Telerik team
answered on 24 Sep 2014, 10:40 AM
Hello Stefania,

You need to specify that multi row editing will be allowed in your RadGrid by setting the AllowMultiRowEdit property to true:
<telerik:RadGrid runat="server" ID="RadGrid1" AllowMultiRowEdit="true">
    <MasterTableView>

Please give this a try and see if you get the desired behavior after applying that change.


Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Mattia
Top achievements
Rank 2
answered on 24 Sep 2014, 01:27 PM
Hi,
thanks! It works perfectly.
0
e
Top achievements
Rank 1
answered on 13 Oct 2014, 04:22 PM
Hi, I am looking for this but instead of the datasource being a database, I want to update a data table.

Thanks!
0
Konstantin Dikov
Telerik team
answered on 16 Oct 2014, 08:49 AM
Hi,

There is no built-in functionality that could allow you to update a DataTable object. The only thing that I could suggest for such requirement is that you save your DataTable object to the Session and modify it manually by traversing through each item of the grid and retrieving the new values. Then, within the OnNeedDataSource event of the grid you could pass the DataTable from the Sessions.

Hope this helps.


Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
abonfig
Top achievements
Rank 1
Answers by
Schlurk
Top achievements
Rank 2
Princy
Top achievements
Rank 2
abonfig
Top achievements
Rank 1
Carl
Telerik team
Neil N
Top achievements
Rank 2
Iron
Iron
Veteran
Mattia
Top achievements
Rank 2
Konstantin Dikov
Telerik team
e
Top achievements
Rank 1
Share this question
or