RadGrid edit mode is not working

8 posts, 0 answers
  1. Helen
    Helen avatar
    4 posts
    Member since:
    Feb 2011

    Posted 14 Mar 2012 Link to this post

    I'm having trouble with my I'm having trouble with my RadGrid - I try show grid in edit mode, but it's not working. I don't know what I miss here. 
        <form id="form1" runat="server">
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="RadGrid1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                        </AjaxSettings>
            </telerik:RadAjaxManager>
                
            <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false"
                        DataSourceID="gridRequest" Edit = "true">
                <MasterTableView EditMode = "InPlace" >
                    <Columns>
                        <telerik:GridBoundColumn DataField="Program" HeaderText="Program" ></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Organization"  HeaderText="Organization"></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Campaign" HeaderText="Campaign" ></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="MinEmployeeCnt" HeaderText="MinEmployeeCnt" ></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="MaxEmployeeCnt" HeaderText="MaxEmployeeCnt" ></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="MinSalesVolume" HeaderText="MinSalesVolume" ></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="MaxSalesVolume" HeaderText="MaxSalesVolume"  ></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="LandLineOnly" HeaderText="LandLineOnly" ></telerik:GridBoundColumn>
                    </Columns>
            </MasterTableView>
        </telerik:RadGrid>
                 
        <asp:ObjectDataSource ID="gridRequest" runat="server" SelectMethod="SelectBusiness" TypeName="G2WebBL.DataMappers.LeadsRequest.LeadsRequestDataAccess">
            <SelectParameters><asp:SessionParameter Name="id" DbType="String" DefaultValue="%" SessionField="ID"  /></SelectParameters>
        </asp:ObjectDataSource>
     
    </form>

  2. Bruno
    Bruno avatar
    20 posts
    Member since:
    Feb 2012

    Posted 14 Mar 2012 Link to this post

    add in your columns tag this code
    <telerik:GridEditCommandColumn ButtonType="ImageButton">
    </telerik:GridEditCommandColumn>
  3. Helen
    Helen avatar
    4 posts
    Member since:
    Feb 2011

    Posted 14 Mar 2012 Link to this post

  4. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 15 Mar 2012 Link to this post

    Hello Helen,

    You can put all items in edit mode without using EditColumn in pageload or prerender as shown below. Let me illustrate.
    1)PageLoad:
    C#:
    protected void Page_Load(object sender, EventArgs e)
    {
     for (int i = 0; i < RadGrid1.PageSize; i++)
     {
       RadGrid1.EditIndexes.Add(i);
     }
    }
    2)PreRender:
    C#:
    protected void RadGrid1_PreRender(object sender, EventArgs e)
    {
     if (!IsPostBack)
     {
      foreach (GridItem item in RadGrid1.MasterTableView.Items)
      {
        if (item is GridEditableItem)
        {
          GridEditableItem editableItem = item as GridDataItem;
          editableItem.Edit = true;
        }
      }
       RadGrid1.Rebind();
     }
    }
    Hope this helps.
    NB: I looked into the code and saw Edit=true within Radgrid. I am not sure if such a property exists for Radgrid. Did you get to type that in?

    Regards,
    Shinu.

  5. Helen
    Helen avatar
    4 posts
    Member since:
    Feb 2011

    Posted 16 Mar 2012 Link to this post

    It works! Thank you so much for your help!
  6. Lee
    Lee avatar
    3 posts
    Member since:
    Sep 2010

    Posted 12 Jun in reply to Shinu Link to this post

    I know this post is pretty old. I needed the same functionality and got it to work with one issue. Only the last row of a multi row grid has the one field editable. I need all the cells of just one column editable. Any help would be great. Thanks,

                            <telerik:RadGrid ID="RMALineItemsRadGridView" runat="server" Edit = "true"
                                Skin="WebBlue" AutoGenerateColumns="False"
                                CellSpacing="-1" GridLines="Both" OnItemCreated="RMALineItemsRadGridView_ItemCreated" OnPreRender="RMALineItemsRadGridView_PreRender" >
                                <MasterTableView ShowHeadersWhenNoRecords="true" Width="2750px" EditMode="InPlace" >
                                    <NoRecordsTemplate>
                                        <div>
                                            There are no records to display
                                        </div>
                                    </NoRecordsTemplate>
                                    <Columns>
                                        <telerik:GridBoundColumn DataField="SONo" DataType="System.String" HeaderText="SO #"
                                            SortExpression="SONo" UniqueName="SONo" Visible="true" ReadOnly="true">
                                            <HeaderStyle Width="100px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="SOLineNo" DataType="System.String" HeaderText="SO Line #"
                                            SortExpression="SOLineNo" UniqueName="SOLineNo" Visible="true" ReadOnly="true">
                                            <HeaderStyle Width="100px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="InvoiceDate" DataType="System.DateTime" DataFormatString="{0:d}" HeaderText="Invoice Date"
                                            SortExpression="InvoiceDate" UniqueName="InvoiceDate" Visible="true" ReadOnly="true">
                                            <HeaderStyle Width="100px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="InvoiceNo" DataType="System.String" HeaderText="Invoice #"
                                            SortExpression="InvoiceNo" UniqueName="InvoiceNo" Visible="true" ReadOnly="true">
                                            <HeaderStyle Width="100px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="ItemCategory" DataType="System.String" HeaderText="Category"
                                            SortExpression="ItemCategory" UniqueName="ItemCategory" Visible="true" ReadOnly="true">
                                            <HeaderStyle Width="150px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="NAVItemNo" DataType="System.String" HeaderText="NAV Item #"
                                            SortExpression="NAVItemNo" UniqueName="NAVItemNo" Visible="true" ReadOnly="true">
                                            <HeaderStyle Width="100px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="Manufacturer" DataType="System.String" HeaderText="Manufacturer"
                                            SortExpression="Manufacturer" UniqueName="Manufacturer" Visible="true" ReadOnly="true">
                                            <HeaderStyle Width="150px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="ManufacturerPartNo" DataType="System.String" HeaderText="Man Part #"
                                            SortExpression="ManufacturerPartNo" UniqueName="ManufacturerPartNo" Visible="true" ReadOnly="true">
                                            <HeaderStyle Width="150px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="Description1" DataType="System.String" HeaderText="Description 1"
                                            SortExpression="Description1" UniqueName="Description1" Visible="true" ReadOnly="true">
                                            <HeaderStyle Width="400px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="Description2" DataType="System.String" HeaderText="Description 2"
                                            SortExpression="Description2" UniqueName="Description2" Visible="true" ReadOnly="true">
                                            <HeaderStyle Width="400px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="QTY" DataType="System.String" HeaderText="QTY"
                                            SortExpression="QTY" UniqueName="QTY" Visible="true">
                                            <HeaderStyle Width="100px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="UnitCost" DataType="System.Decimal" DataFormatString="{0:C}" HeaderText="Unit Cost"
                                            SortExpression="UnitCost" UniqueName="UnitCost" Visible="true" ReadOnly="true">
                                            <HeaderStyle Width="100px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="UnitPrice" DataType="System.Decimal" DataFormatString="{0:C}" HeaderText="Unit Price"
                                            SortExpression="UnitPrice" UniqueName="UnitPrice" Visible="true" ReadOnly="true">
                                            <HeaderStyle Width="100px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="ExtCost" DataType="System.Decimal" DataFormatString="{0:C}" HeaderText="Ext Cost"
                                            SortExpression="ExtCost" UniqueName="ExtCost" Visible="true" ReadOnly="true">
                                            <HeaderStyle Width="100px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="ExtPrice" DataType="System.Decimal" DataFormatString="{0:C}" HeaderText="Ext Price"
                                            SortExpression="ExtPrice" UniqueName="ExtPrice" Visible="true" ReadOnly="true">
                                            <HeaderStyle Width="100px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="GPDollar" DataType="System.Decimal" DataFormatString="{0:C}" HeaderText="GP Dollar"
                                            SortExpression="GPDollar" UniqueName="GPDollar" Visible="true" ReadOnly="true">
                                            <HeaderStyle Width="100px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="SupplierID" DataType="System.String" HeaderText="SupplierID"
                                            SortExpression="SupplierID" UniqueName="SupplierID" Visible="true"  ReadOnly="true">
                                            <HeaderStyle Width="100px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="Supplier" DataType="System.String" HeaderText="Supplier"
                                            SortExpression="" UniqueName="" Visible="true"  ReadOnly="true">
                                            <HeaderStyle Width="200px" />
                                        </telerik:GridBoundColumn>


                                        <%-- <telerik:GridBoundColumn datafield="" datatype="System.String" headertext=""
                                        sortexpression="" uniquename="" Visible="true">
                                    </telerik:GridBoundColumn>--%>
                                    </Columns>
                                </MasterTableView>
                            </telerik:RadGrid>

     

            protected void RMALineItemsRadGridView_PreRender(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    foreach (GridItem item in RMALineItemsRadGridView.MasterTableView.Items)
                    {
                        if (item is GridEditableItem)
                        {
                            GridEditableItem editableItem = item as GridDataItem;
                            editableItem.Edit = true;
                        }
                    }

                    RMALineItemsRadGridView.Rebind();
                }
            }

     

  7. Lee
    Lee avatar
    1 posts
    Member since:
    Jun 2019

    Posted 13 Jun in reply to Lee Link to this post

    Okay, I found this for the table which makes all rows for the Quantity column editable:

    AllowMultiRowEdit="true"

    No my problem is that when I change the values for the column and then attempt to loop through the table values I don't get any values. It seems like I have to flip the table out of edit mode. Anyone have any thoughts on that?

  8. Peter Milchev
    Admin
    Peter Milchev avatar
    568 posts

    Posted 14 Jun Link to this post

    Hello Lee,

    You can check the following Code Library that achieves row and column editing: https://www.telerik.com/support/code-library/edit-all-cells-of-a-specific-column-with-radgrid-using-inplace-editing.

    Regards,
    Peter Milchev
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top