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

[Solved] Cannot get grid to go into inline edit mode with templates.

7 Answers 240 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
MarkNic
Top achievements
Rank 1
MarkNic asked on 19 Jul 2010, 03:25 PM

Hi,

I have been following along with the example code included with the MVC extensions for doing inline editing.  I am using Server Binding and have created display and editor templates for the 2 needed drop-downs.  Below is the EditData.aspx file with all the bindings. 

The grid appears as it should but when I click edit the page posts but does not go into edit mode.

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<EditableWeeklyStatistic>>" %>
<%@ Register assembly="System.Web.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" namespace="System.Web.UI.WebControls" tagprefix="asp" %>
  
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Data Entry
</asp:Content>
  
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
        <%= Html.Telerik().Grid(Model)
            .Name("Grid")
            .DataKeys(keys =>
            {
                keys.Add(w => w.Id).RouteKey("Id");
                keys.Add(w => w.LocationId).RouteKey("LocationId");
                keys.Add(w => w.ReportWeek).RouteKey("ReportWeek");
            })
            .DataBinding(dataBinding => dataBinding.Server()
                                            .Select("EditData", "Status")
                                            .Update("UpdateWeeklyStatistic", "Status"))
            .Columns(columns =>
            {
                columns.Bound(w => w.Id).Width(60).ReadOnly();
                columns.Bound(w => w.MetricDescription).Width(200).ReadOnly();
                columns.Bound(w => w.PercentComplete).Width(130);
                columns.Bound(w => w.TrackingToETC).Width(100).Title("Tracking to ETC");
                columns.Bound(w => w.Blockers).Width(130);
                columns.Bound(w => w.ETCDate).Width(130).Title("ETC Date");
                columns.Command(commands => commands.Edit()).Width(180).Title("Edit");
            })
            .Scrollable(scrolling => scrolling.Height(1000))
            .Sortable()
            .Pageable(paging => paging.PageSize(20)
            .Style(GridPagerStyles.NextPreviousAndNumeric)
            .Position(GridPagerPosition.Both))
        %>
</asp:Content>

As you can see, there are 3 keys to the db table that I am using.  PercentComplete and Blockers are supposed to be the drop-downs.  I did try commenting out those 2 columns to see if it was the drop-downs causing the issue but it still did not go into edit mode.

I've been over and over the code comparing all the components to the example: Views, templates (display templates do work just fine), controller, editable object, TypeConverter code, etc. but can't seem to find the issue.

FYI: using EF, MVC2, version 416 of the extensions. 

Any help would be greatly appreciated.  Thanks.

7 Answers, 1 is accepted

Sort by
0
sebrojas
Top achievements
Rank 1
answered on 19 Jul 2010, 05:01 PM
Hello, please try adding this line:

.Editable(editing => editing.Mode(GridEditMode.InLine))

If not, let me know so I search more deeply
0
MarkNic
Top achievements
Rank 1
answered on 19 Jul 2010, 05:19 PM
Thanks for the quick reply but does that work in the MVC extensions?  I added that line but got this:

.Editable(editing => editing.Mode(GridEditMode.InLine))

Mode and GridEditMode couldn't be resolved.
0
sebrojas
Top achievements
Rank 1
answered on 19 Jul 2010, 05:43 PM
Oh yes sorry, I think this is for the Q2 realise, sorry
0
MarkNic
Top achievements
Rank 1
answered on 20 Jul 2010, 05:20 AM
I upgraded my project using the Telerik upgrade wizard to version 2010.2.713.235, added the .Editable(...) line from above and it behaves the same - Clicking on Edit just does a post and refreshes, it does not go into edit mode.

Is there something else I should be looking at????
0
MarkNic
Top achievements
Rank 1
answered on 22 Jul 2010, 08:35 PM

Well, i seem to have solved my own problem of getting the inline edit to display. 

This is the code i started with:

<%= Html.Telerik().Grid(Model) 
            .Name("Grid") 
            .DataKeys(keys => 
            
                keys.Add(w => w.Id).RouteKey("Id"); 
                keys.Add(w => w.LocationId).RouteKey("LocationId"); 
                keys.Add(w => w.ReportWeek).RouteKey("ReportWeek"); 
            }) 

Just for grins, i commented out the last 2 key statements and when I ran the app, the inline edit appeared.  It didn't work right but it made me believe that you can't have more than 1 key.  So I rearanged my table in the database to only utilize a single key field.

Now, with this...
<%=Html.Telerik()
          .Grid(Model)
          .Name("Grid")
          .DataKeys(keys => keys.Add(w => w.PrimaryKey).RouteKey("id"))
it works.


0
sebrojas
Top achievements
Rank 1
answered on 22 Jul 2010, 08:52 PM
It's posible, good for you
0
Andrew
Top achievements
Rank 1
answered on 05 Sep 2010, 11:45 PM
I'll add to that. I don't think multiple DataKeys works. I have:

<%= Html.Telerik().Grid<BankAccountEntry>()
        .Name("Accounts")
        .ToolBar(commands => commands.Insert())
        .DataKeys(keys => 
        {
            keys.Add(b => b.Id).RouteKey("id");
            keys.Add(b => b.Stamp).RouteKey("stamp");
        })
        .DataBinding(dataBinding =>
        {
            dataBinding.Ajax()
                .Insert("InsertStatement""Accounts")
                .Select("SelectStatement""Accounts")
                .Update("SaveStatement""Accounts");

        })
        .Columns(columns =>
        {
            columns.Bound(b => b.EntryDate).Width(9).Format("{0:dd/MM/yyyy}");
            columns.Bound(b => b.Memo).Width(30);
            columns.Bound(b => b.Comment).Width(25);
            columns.Bound(b => b.AmountText).Width(10).Title("Amount");
            columns.Command(commands =>
            {
                commands.Edit();
            }).Width(20);

        })
        .Pageable(paging => paging.PageSize(20))
        .Filterable()
        .Sortable()
        .Groupable()
        .Selectable()
        .Scrollable(scroll =>
        {
            scroll.Enabled(false);
            scroll.Height(400);
        })
    %>

and a save method

 [AcceptVerbs(HttpVerbs.Post)]
        [GridAction]
        public ActionResult SaveStatement(string id, byte[] stamp)
        {
            foo....
        }

But the stamp parameter is always null.
I have Q2 2010.
Tags
Grid
Asked by
MarkNic
Top achievements
Rank 1
Answers by
sebrojas
Top achievements
Rank 1
MarkNic
Top achievements
Rank 1
Andrew
Top achievements
Rank 1
Share this question
or