Custom popup editor problem

5 posts, 0 answers
  1. license
    license avatar
    2 posts
    Member since:
    Nov 2010

    Posted 17 Dec 2012 Link to this post

    Hi,
    We use MVC 4 and EF 4.5.
    I have grid with " .Editable(e => e.Mode(GridEditMode.PopUp).TemplateName("Company"))".
    My EditorTemplate looks like this:

    ...
     <div class="editor-label">
            @Html.LabelFor(model => model.CompanyUrl)
        </div>
        <div class="editor-field">
            @Html.DisplayFor(model => model.CompanyUrl)
        </div>
     
        <div class="editor-label">
            @Html.LabelFor(model => model.FirstName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.FirstName)
            @Html.ValidationMessageFor(model => model.FirstName)
        </div>
    ...
    I want the field "CompanyUrl" to be readonly and for that I call "DisplayFor" but when I click for editing DisplayFor shows
    nothing. 

    When I'm using GridEditMode.InLine and  m.Field(f => f.CompanyUrl).DefaultValue(string.Empty).Editable(false); everything is OK. I want to use popup because my class has too many fields and  default popup editor shows too many unwanted fields.
    Am I doing something wrong ?
    Thanks

    P.S One more thing. I want a field edited with kendo editor to be shown formatted in the grid column, not like now "<p>Some Text</p><p><strong>New Line</strong></p>
    ".
    The column is in  " .ClientDetailTemplateId("clientCommentsTemplate")" 
  2. Chris
    Chris avatar
    1 posts
    Member since:
    Aug 2012

    Posted 17 Dec 2012 Link to this post

    I'm having the same issue.

    Below is my Custom Popup

    @model RenewalMemberViewModel
                
    @Html.HiddenFor( model => model.MembershipNumber )
     
    <div class="editor-label">
        @Html.LabelFor( model => model.Name )
    </div>
    <div class="editor-field">
        @Html.DisplayFor(model => model.Name )
    </div>
    <div class="editor-label">
        @Html.LabelFor( model => model.MembershipNumber )
    </div>
    <div class="editor-field">
        @Html.DisplayFor( model => model.MembershipNumber )
    </div>
    <div class="editor-label">
        @Html.LabelFor( model => model.MembershipType )
    </div>
    <div class="editor-field">
        @Html.EditorFor( model => model.MembershipType )
        @Html.ValidationMessageFor( model => model.MembershipType )
    </div>
    <div class="editor-label">
        @Html.LabelFor( model => model.ExpDate )
    </div>
    <div class="editor-field">
        @Html.DisplayFor( model => model.ExpDate )
    </div>
    None of the DisplayFor s work. If i replace them with EditorFor it properly displays a text box editor populated with the correct data but these fields are meant to be read only in this pop-up. Any help would be appreciated.
  3. Daniel
    Admin
    Daniel avatar
    2224 posts

    Posted 19 Dec 2012 Link to this post

    Hello,

    The DisplayFor helper will not work when using Ajax binding because it just outputs the value and there is no way to determine that the value should be shown on the client. Instead, you should use text binding for the property e.g.

    <div class="editor-label">
            @Html.LabelFor(model => model.CompanyUrl)
    </div>
    <div class="editor-field">
        <span data-bind="text: CompanyUrl"></span>
    </div>
    Regards,
    Daniel
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  4. Sindhura
    Sindhura avatar
    6 posts
    Member since:
    Apr 2014

    Posted 24 Aug 2015 in reply to Daniel Link to this post

    Hi Daniel,

    Is there a way I could get the value into a html variable of the popup editor template?

    Something like this :
    @{
    var value = Model.Name; //get the value of Name in the model
    }

    Or is it possible to access this value using Javascript in editor template? For example:
    <script>
    var value = @Model.Name;  //get the value of Name in the model
    </script>

    Thanks in advance.

  5. Daniel
    Admin
    Daniel avatar
    2224 posts

    Posted 26 Aug 2015 Link to this post

    Hi,

    No, it is not possible to access the value on the server if you are using Ajax binding for the grid. Accessing the value with the JavaScript code that you provided will also not work. You can access the value in the grid edit event.

    Regards,
    Daniel
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
Back to Top