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

[Solved] Edit Template for ViewModel not called

7 Answers 100 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.
Michael
Top achievements
Rank 1
Michael asked on 13 Apr 2011, 11:30 PM
I have 2 grids on a tabstrip...one calls the edittemplate for the viewmodel of its grid...the other doesn't

As far as i can see the code is identical for both.

The editemplate is named the same as the viewmodel and sits in the EditorTemplates folder (ive even tried placing it tin the shared folder as well)

The grid is passed (and displays) the viewmodel in each case...I'm just at a loss to know what sort of things may be broken??
The edittemplate in each case is named ResultViewModel and MemberViewModelSimple (as per the respective grids)

I just cant see what difference there is for it not to be called in case2??
What sort of things shouldi be looking at?? the controllers pass the data almost identically...


heres the view code:
This one works
@(Html.Telerik().Grid<WAC_MVC.ViewModels.ResultViewModel>()
                           .Name("ResultGrid")
                           .DataKeys(datakey => datakey.Add(r => r.ResultID))
                           .ToolBar(commands => commands.Insert())
                           .HtmlAttributes(new { style = "border: 0;" })
                           .Columns(columns =>
                           {
                               columns.Bound(o => o.FullName).Width(180);
                               columns.Bound(o => o.GroupID).Width(40);
                               columns.Bound(o => o.RaceName);
                               columns.Bound(o => o.kmRateString);
                               columns.Bound(o => o.ActualTimeString).Format("{0:hh\\:mm\\:ss}").Width(90);
                               columns.Bound(o => o.strHandicap).Width(90).Format("{0:mm\\:ss}");
                               columns.Bound(o => o.HandicapTime).Format("{0:hh\\:mm\\:ss}").Width(90);
                               columns.Command(command => command.Edit());
 
                           })
                           .DataBinding(dataBinding => dataBinding.Ajax()
                               .Select("_ResultsForEditing", "handicapper")
                               .Insert("Insert", "Handicapper")
                               .Update("_SaveAjax", "Handicapper"))
                           .Pageable(paging => paging.PageSize(40))
                           .Scrollable(scrollable => scrollable.Height("300px"))
                           .Filterable(filter =>filter.Enabled(true))
                           .Sortable(config => config
                               .OrderBy(order => order
                                   .Add(((string)ViewData["view"]) == "sortedByDate" ? "ActualTimeString" :
                                       "FullName")
                               )
                           )
                           .Groupable(groupable => groupable.Enabled(true))
                           .Editable(editing => editing.Mode(GridEditMode.PopUp))
                         )


and this one doesnt:

@(Html.Telerik().Grid<WAC_MVC.ViewModels.MemberViewModelSimple>()
        .Name("Members")
        .DataKeys(key => key.Add(m => m.mMemberID))
        .ToolBar(commands => commands.Insert())
        .HtmlAttributes(new { style = "border: 0;" })
        .Columns(col =>
            {
                col.Bound(m => m.mFName).Width(60);
                col.Bound(m => m.mSName).Width(60);
                col.Bound(m => m.mMale).Width(80);
                col.Bound(m => m.MembershipMembership1).Width(80);
            })
         .DataBinding(dataBinding => dataBinding.Ajax()
             .Select("Members", "HCMember")
             .Insert("_InsertMember", "HCMember"))
        .Pageable(paging => paging.PageSize(20))
        .Scrollable(scrolling => scrolling.Height(580))
        .Editable(editing=> editing.Mode(GridEditMode.PopUp))
        .Sortable()
        .Filterable()
         
)

7 Answers, 1 is accepted

Sort by
0
Michael
Top achievements
Rank 1
answered on 13 Apr 2011, 11:44 PM
ok could it be as simpkle as i havent written the update code yet....?
0
Michael
Top achievements
Rank 1
answered on 16 Apr 2011, 11:44 PM
Yes it was...seems like you need to have all the commands stubbed for the tepmplate to even show in either scenario....

so if i only wanted to add from a template I would still need the update command??
0
Atanas Korchev
Telerik team
answered on 18 Apr 2011, 07:22 AM
Hi Michael,

I do not understand what the problem is. Could you please try clarifying what you mean by "so if i only wanted to add from a template I would still need the update command" ?

Greetings,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Michael
Top achievements
Rank 1
answered on 18 Apr 2011, 02:44 PM
I mean this line from the grid was missing the .Update, which i hadnt implemented cos i was building up the functionality slowly and starting with Insert only.


.DataBinding(dataBinding => dataBinding.Ajax()
     .Select("Members", "HCMember")
     .Insert("_InsertMember", "HCMember"))
0
Atanas Korchev
Telerik team
answered on 18 Apr 2011, 03:33 PM
Hi Michael,

 The grid should  throw an exception if you declare an Edit command and don't define Update data binding setting. This is done for convenience - to remind the developer that the grid is not completely configured.

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Michael
Top achievements
Rank 1
answered on 18 Apr 2011, 11:13 PM
I didnt declare an edit command only an insert, and it failed to render the edittemplate (for an insert) until the
.update was declared
0
Atanas Korchev
Telerik team
answered on 19 Apr 2011, 07:00 AM
Hi Michael,

 I am not sure I understand the problem. Perhaps it is best to provide a sample project or paste how the grid declaration looks like and a screenshot showing the erroneous behavior.

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Michael
Top achievements
Rank 1
Answers by
Michael
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or