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

[Solved] Cannot bind editor template to grid model

0 Answers 53 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.
Developer Developer
Top achievements
Rank 1
Developer Developer asked on 22 Feb 2012, 11:14 AM
Hi
I need to add a look up button next to the text field and have create an editor template in order for this to work in edit mode.
But i'm not able to bind the editor template against the grid model. Once I have changed the value in editortemplate and exit edit mode
the value shows object object in the textfield. How can the editor template be bound the the grid Model? Do i have to popuplate the editortemplate ongridedit and repopulate the main textbox in grid on gridsave?

Below is the code snippet from my grid and editor template:

 if (Model.IsEditMode)
            {
                columns.Bound(dto => dto.PipingSpoolId)
                    .ClientTemplate("<input id='chkRow' class='grid-checkbox gridrow-checkbox' type='checkbox' value='<#= PipingSpoolId #>' onchange='' />")
                    .HeaderTemplate("<input id='chkAllRows' class='grid-checkbox' type='checkbox' onchange='ProCoSys.grideditable.toggleAllRows()' />")
                    .HtmlAttributes(new {align = "center"})
                    .HeaderHtmlAttributes(new {style = "text-align:center"})
                    .Width(30).ReadOnly();

                columns.Bound(dto => dto.IsoDrawing).Width(75).Title(CompletionStrings.PipingSpoolGrid_IsoDrawing).
                    EditorTemplateName("EditTextFieldWithLookup");
            }

EditTextFieldWithLookup

@using Statoil.ProCoSysNextGen.Web.ViewHelpers.Lookup
@model Statoil.ProCoSysNextGen.Web.Controllers.Completion.ViewModels.McPkgPipingSpoolsViewModel

@{
    var guidId = Guid.NewGuid().ToString();
    @Html.TextBox(guidId, @Model).Lookup(LookupType.TAG);                                                                                     
}

Regards
Son



Tags
Grid
Asked by
Developer Developer
Top achievements
Rank 1
Share this question
or