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

[Solved] Display/Edit Template

3 Answers 186 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.
El Roy
Top achievements
Rank 1
El Roy asked on 19 Jul 2010, 06:20 PM
I followed the example in http://demos.telerik.com/aspnet-mvc/Grid/DisplayAndEditTemplates.  But
instead of Server binding I am using Ajax binding.  I notice that on edit mode the model gets NULL
in the .ASCX user control, am I missing something?

3 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 20 Jul 2010, 07:05 AM
Hi El Roy,

This is actually normal. The Model is server side property whilst client templates operate on the client-side and have no notion of what model is. For ajax binding we suggest using client-side templates and the onRowDataBound client-side event.

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
Ammar
Top achievements
Rank 1
answered on 31 Aug 2011, 03:57 PM
Hi Atanas,

Can you please provide an example of Grid Ajax binding client-side templates and the onRowDataBound client-side event to pre-select  the value of drop down.

Like below code snippet on how you you implement for Server binding.
@(Html.Telerik().DropDownList()
            .Name(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))
            .BindTo(new SelectList((IEnumerable)Proficiency.ListOfProficiency, "Id", "Name", Model.Id.ToString())))

As you mentioned with Ajax binding Model is always null, as Model is server side property.

Regards,
Ammar
0
Atanas Korchev
Telerik team
answered on 01 Sep 2011, 08:11 AM
Hello Ammar,

 Should be something like this:


function onRowDataBound(e) {
      var dropdown = $(e.row).find(".t-dropdown input").data("tDropDownList")

      dropdown.value(e.dataItem.SomeValue);
}

Kind regards,
Atanas Korchev
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
Grid
Asked by
El Roy
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Ammar
Top achievements
Rank 1
Share this question
or