inplace editing not working

7 posts, 0 answers
  1. mww
    mww avatar
    257 posts
    Member since:
    Sep 2012

    Posted 06 Oct 2009 Link to this post

    I have a grid with 3 columns, a combo box, text box and numeric box.  Its been working ok, then suddenly for no reason I can see it will no longer switch to edit mode.  I can insert new rows and delet existing rows, but clicking the edit button does nothing.  Can anyone see what the hell could have happened here ?  It juststopped working and I cant see why

    <telerik:RadGrid ID="RadGridCastList" GridLines="None"   
                AutoGenerateColumns="false" PageSize="10" 
                AllowPaging="true" AllowSorting="false" runat="server" Skin="Vista"   
                onneeddatasource="RadGridCastList_NeedDataSource" OnUpdateCommand="RadGridCast_UpdateCommand" 
                OnItemCreated="RadGridCast_ItemCreated" OnDeleteCommand="RadGridCast_DeleteCommand" 
                OnInsertCommand="RadGridCast_InsertCommand"   
                onitemdatabound="RadGridCast_ItemDataBound" Width="100%"   
                HorizontalAlign="Left" > 
                  
                <MasterTableView ShowFooter="false" DataKeyNames="ID" EditMode="InPlace" CommandItemDisplay="Top" InsertItemPageIndexAction="ShowItemOnCurrentPage" Name="CastlistMembers">  
                    <Columns> 
                      
                                              
                        <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">  
                            </telerik:GridEditCommandColumn> 
                              
                          
                        <telerik:GridTemplateColumn UniqueName="CastMember" HeaderText="Cast Member" 
                            SortExpression="CastMember">  
                              
                            <ItemTemplate> 
                                <%#DataBinder.Eval(Container.DataItem, "CastMemberName")%> 
                            </ItemTemplate> 
                            <EditItemTemplate> 
                                <telerik:RadComboBox DataTextField="CastMemberName"   
                                 DataValueField="CastMemberID"   
                                 OnItemsRequested="RadComboBox1_ItemsRequested" 
                                    EnableLoadOnDemand="True"   
                                    ID="RadComboBox1"   
                                    runat="server"   
                                    Width="220px"   
                                    SelectedValue='<%#Bind("CastMemberName") %>'>  
                                </telerik:RadComboBox> 
                            </EditItemTemplate> 
                        </telerik:GridTemplateColumn> 
                          
                        <telerik:GridTemplateColumn HeaderText="Role" UniqueName="CastMemberRole" DataField="CastMemberRole">  
                            <ItemTemplate> 
                                <asp:Label ID="lblCastMemberRole" runat="server" Text='<%# Eval("CastMemberRole") %>' /> 
                            </ItemTemplate> 
                            <EditItemTemplate> 
                                <telerik:RadTextBox ID="txbCastMemberRole" Width="300px" runat="server" TextMode="SingleLine" 
                                    Text='<%# Bind("CastMemberRole") %>' /> 
                            </EditItemTemplate> 
                            <ItemStyle VerticalAlign="Top" /> 
                        </telerik:GridTemplateColumn> 
                          
                        <telerik:GridTemplateColumn UniqueName="DisplayOrder" HeaderText="Display Order" 
                            SortExpression="DisplayOrder">  
                              
                            <ItemTemplate> 
                                <%#DataBinder.Eval(Container.DataItem, "DisplayOrder")%> 
                            </ItemTemplate> 
                            <EditItemTemplate> 
                                <telerik:RadNumericTextBox ID="RadNumericTextBoxDisplayOrder" runat="server" DataType="System.Int" MinValue="0" NumberFormat-DecimalDigits="0">  
                                </telerik:RadNumericTextBox>   
                            </EditItemTemplate> 
                        </telerik:GridTemplateColumn> 
                          
                         <telerik:GridButtonColumn ConfirmText="Delete this cast list member ?" ButtonType="ImageButton" 
                                            CommandName="Delete" Text="Delete" UniqueName="DeleteColumn1">  
                                            <HeaderStyle Width="20px" /> 
                                            <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" /> 
                                        </telerik:GridButtonColumn> 
                                          
                    </Columns> 
     
     
    <EditFormSettings> 
    <EditColumn UniqueName="EditCommandColumn1"></EditColumn> 
    </EditFormSettings> 
                    <PagerStyle AlwaysVisible="True" /> 
     
     
                </MasterTableView> 
            </telerik:RadGrid> 
  2. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 06 Oct 2009 Link to this post

    Hi Mark,

    I recommend you examine the following links and see what is the difference in your scenario:
    Edit on Double-click
    In place - Help topic

    Best wishes,
    Pavlina
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. mww
    mww avatar
    257 posts
    Member since:
    Sep 2012

    Posted 06 Oct 2009 Link to this post

    nothing I can do will activate edit mode !

    ive stripped the grid right back to basics (using the example you supplied) and added my columns, thwn Ive stepped though my code in the ItemCreated event and I never get a GridEditableItem, I get this sequences as I step though
    GridCommandItem
    GridDataItem
    GridDataItem
    GridDataItem
    GridDataItem
    GridFooterItem
    GridPagerItem
    GridCommandItem
    GridPagerItem
    GridHeaderItem

    so how can the grid ever switch to edit mode.  Can you look at my markup and tell me what Im douing wrong ?

    <telerik:RadGrid  
           ID="RadGridCastList" runat="server" 
           GridLines="None" onitemcreated="RadGridCastList_ItemCreated"   
           onneeddatasource="RadGridCastList_NeedDataSource" AllowPaging="True"   
                AutoGenerateColumns="False" Skin="Vista">  
         <MasterTableView  DataKeyNames="ID" EditMode="InPlace" CommandItemDisplay="Top" Name="CastlistMembers">  
           <Columns> 
               
                      
                                              
                        <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">  
                            </telerik:GridEditCommandColumn> 
                              
                          
                        <telerik:GridTemplateColumn UniqueName="CastMember" HeaderText="Cast Member" 
                            SortExpression="CastMember">  
                              
                            <ItemTemplate> 
                                <%#DataBinder.Eval(Container.DataItem, "CastMemberName")%> 
                            </ItemTemplate> 
                            <EditItemTemplate> 
                                <telerik:RadComboBox DataTextField="CastMemberName"   
                                 DataValueField="CastMemberID"   
                                 OnItemsRequested="RadComboBoxCastMember_ItemsRequested" 
                                    EnableLoadOnDemand="True"   
                                    ID="RadComboBoxCastMember"   
                                    runat="server"   
                                    Width="220px"   
                                    SelectedValue='<%#Bind("CastMemberName") %>'>  
                                </telerik:RadComboBox> 
                            </EditItemTemplate> 
                        </telerik:GridTemplateColumn> 
                          
                        <telerik:GridTemplateColumn HeaderText="Role" UniqueName="CastMemberRole" DataField="CastMemberRole">  
                            <ItemTemplate> 
                                <asp:Label ID="lblCastMemberRole" runat="server" Text='<%# Eval("CastMemberRole") %>' /> 
                            </ItemTemplate> 
                            <EditItemTemplate> 
                                <telerik:RadTextBox ID="txbCastMemberRole" Width="300px" runat="server" TextMode="SingleLine" 
                                    Text='<%# Bind("CastMemberRole") %>' /> 
                            </EditItemTemplate> 
                            <ItemStyle VerticalAlign="Top" /> 
                        </telerik:GridTemplateColumn> 
                          
                        <telerik:GridTemplateColumn UniqueName="DisplayOrder" HeaderText="Display Order" 
                            SortExpression="DisplayOrder">  
                              
                            <ItemTemplate> 
                                <%#DataBinder.Eval(Container.DataItem, "DisplayOrder")%> 
                            </ItemTemplate> 
                            <EditItemTemplate> 
                                <telerik:RadNumericTextBox ID="RadNumericTextBoxDisplayOrder" runat="server" DataType="System.Int" MinValue="0" NumberFormat-DecimalDigits="0">  
                                </telerik:RadNumericTextBox>   
                            </EditItemTemplate> 
                        </telerik:GridTemplateColumn> 
                          
                         <telerik:GridButtonColumn ConfirmText="Delete this cast list member ?" ButtonType="ImageButton" 
                                            CommandName="Delete" Text="Delete" UniqueName="DeleteColumn1">  
                                            <HeaderStyle Width="20px" /> 
                                            <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" /> 
                                        </telerik:GridButtonColumn> 
                                          
                      
            </Columns> 
     
    <EditFormSettings> 
    <EditColumn UniqueName="EditCommandColumn1"></EditColumn> 
    </EditFormSettings> 
     
         </MasterTableView> 
        </telerik:RadGrid>  


    protected void RadGridCastList_ItemCreated(object sender, GridItemEventArgs e)  
            {  
                if (e.Item is GridDataItem)  ----  e.Item IS NEVER GridEditableItem  
                {  
                    //the item is in regular mode  
                    GridDataItem dataItem = e.Item as GridDataItem;  
                    //do something here  
                }  
                else if (e.Item is GridEditableItem && e.Item.IsInEditMode)  
                {  
                    //the item is in edit mode  
                      
                    //do something here  
                }  
     
            }  
     
  5. mww
    mww avatar
    257 posts
    Member since:
    Sep 2012

    Posted 06 Oct 2009 Link to this post

    It looks to me like there is a bug when trying to set in place editing if the RADGrid is inside a RADWindow, thats the only difference I can think of compared to other places ive used this form of editing
  6. Rick Miller
    Rick Miller avatar
    1 posts
    Member since:
    Sep 2009

    Posted 07 Oct 2009 Link to this post

    I think the problem is that GridDataItem is a subclass of GridEditableItem, so you'll never hit your second condition. The way I read the documents, just about everything you see is GridEditable - including headers & footers. The dynamic (data) portion of the grid is GridData - so it looks like you're processing the GridDataItems (not testing to see if they're in edit mode) and never getting to your "else" condition.

    Try moving your snippet "&& e.Item.IsInEditMode" to right after the "e.Item is GridDataItem" statement (move your edit logic there as well). Better yet,
    if (e.Item is GridDataItem)
    {
        if (e.Item.IsInEditMode)
            {//do your editing thing here}
         else
            {// do your non-editing thing here}
    }

    and forget about the "is GridEditableItem ".

    If you're in the Telerik help system, here's the help reference on GridDataItem: 
        ms-help://telerik.aspnetajax.radcontrols.2009.Q2/telerik.aspnetajax.radgrid.2009.Q2/data-items.html
    and this shows the hierarchy:
    ms-help://telerik.aspnetajax.radcontrols.2009.Q2/telerik.aspnetajax.radcontrols.api.2009.Q2/Telerik.Web.UI~Telerik.Web.UI.GridDataItem.html

    HTH
  7. mww
    mww avatar
    257 posts
    Member since:
    Sep 2012

    Posted 07 Oct 2009 Link to this post

    afrer some tweaking I finally managed to get the in place editing to work.  The problem now though is that the 'Items_requested' functionality no longer works.  Becuase the combo could contain many names, I implemented the

    OnItemsRequested

    functionality, like this

    <telerik:GridTemplateColumn UniqueName="CastMember" HeaderText="Cast Member" DataField="CastMemberName" 
                            SortExpression="CastMember" ItemStyle-HorizontalAlign="Left">  
                              
                            <ItemTemplate> 
                                <%#DataBinder.Eval(Container.DataItem, "CastMemberName")%> 
                            </ItemTemplate> 
                            <EditItemTemplate> 
                                <telerik:RadComboBox DataTextField="CastMemberName" Skin="Vista" 
                                 DataValueField="CastMemberID"   
                                 OnItemsRequested="RadComboBoxCastMember_ItemsRequested" 
                                    EnableLoadOnDemand="True"   
                                    ID="RadComboBoxCastMember"   
                                    runat="server"   
                                    Width="220px" > 
                                </telerik:RadComboBox> 
                            </EditItemTemplate> 
     
    <ItemStyle HorizontalAlign="Left"></ItemStyle> 
                        </telerik:GridTemplateColumn> 


    protected void RadGridCastList_ItemCreated(object sender, GridItemEventArgs e)  
            {  
                if (e.Item is GridDataItem)  
                {  
                    if (e.Item.IsInEditMode)  
                    {  
                        GridEditableItem eeditItem = e.Item as GridEditableItem;  
                        RadComboBox combo = (RadComboBox)editItem.FindControl("RadComboBoxCastMember");  
                        combo.DataTextField = "CastMemberName";  
                        combo.DataValueField = "CastMemberName";  
                        combo.DataSource = castmanager.AllCastMembers();  
                        combo.DataBind();  
                        try  
                        {  
                            combo.FindItemByValue(DataBinder.Eval(e.Item.DataItem, "CastMemberName").ToString()).Selected = true;  
                        }  
                        catch (NullReferenceException ex)  
                        {  
                            //  
                        }  
     
                        RadNumericTextBox rntb = (RadNumericTextBox)editItem.FindControl("RadNumericTextBoxDisplayOrder");  
                        try  
                        {  
                            rntb.DbValue = (int)DataBinder.Eval(e.Item.DataItem, "DisplayOrder");  
                        }  
                        catch (Exception ex2)  
                        {  
                            //  
                        }  
                    }  
                    else  
                    {  
     
                    }  
                }  
                  
     
            }  
            protected void RadComboBoxCastMember_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)  
            {  
     
                List<TheCompanyBL.CastMemberListObj> lst = new List<TheCompanyBL.CastMemberListObj>();  
                lst = castmanager.CastMembers(e.Text);  
     
                RadComboBox comboBox = (RadComboBox)sender;  
                comboBox.Items.Clear();  
                foreach (TheCompanyBL.CastMemberListObj member in lst)  
                {  
                    RadComboBoxItem item = new RadComboBoxItem();  
                    item.Text = member.CastMemberName;  
                    item.Value = member.ID.ToString();  
                    comboBox.Items.Add(item);  
                }  
            } 
      How can I reinstate this functioanlity ?
  8. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 09 Oct 2009 Link to this post

    Hi,

    You can use "TextChanged" EventHandler instead of "ItemsRequested" for adding RadComboBox items. 
    Additionally, I believe you will find the following  example useful.
     
    I hope this information helps.

    Regards,
    Pavlina
    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017