edit popup in grid

2 posts, 0 answers
  1. Giorgio
    Giorgio avatar
    1 posts
    Member since:
    May 2017

    Posted 02 Oct 2017 Link to this post

    Hello,

    I have an edit template for the edit popup in the grid,

    but when I make update some fields are empty, the bind doesn't work.

    This is the view:

    @model OrdiniCRA.ViewModels.Customers.OrderDetailViewModel

    <br />

    @Html.AntiForgeryToken()

    @Html.HiddenFor(model => model.PurchaseOrdId)
    @Html.HiddenFor(model => model.Position)
    @Html.HiddenFor(model => model.Line)
    @Html.HiddenFor(model => model.Supplier)
    @Html.HiddenFor(model => model.TotalAmount)



    <div  id="ch" class="col-md-offset-4 col-md-10">

        @(Html.Kendo().CheckBox().Name("ArtFornit").Checked(false).Label("Filtra per articolo fornitore").HtmlAttributes(new { onchange = "updateMsg();" }))
    </div>
       
     


    <div class="col-md-offset-4 col-md-8">
        @Html.Label("Tipo Riga")
    </div>
    <div class="col-md-offset-4 col-md-8">
       @Html.Kendo().DropDownListFor(m => m).DataTextField("Text").Name("LineType").DataValueField("Text").Value("MERCE").Events(e => e.Select("onSelect")).BindTo(new List<SelectListItem>() {
                  new SelectListItem() {
                      Text = "MERCE",
                      Value = "3538947"
                  },
                  new SelectListItem() {
                      Text = "NOTA",
                      Value = "3538944"
                  }
              }).Value("MERCE")

      
        @Html.ValidationMessageFor(model => model.LineType)
    </div>


    <div id="lart" class="col-md-offset-4 col-md-8">
        @Html.LabelFor(model=>model.Item)
    </div>
        <div class="col-md-offset-4 col-md-8">

            @(
     Html.Kendo().ComboBoxFor(m => m.Item).Name("Item")
           .Height(400).HeaderTemplate("<div class=\"dropdown-header k-widget k-header\"><span>Codice </span><span>Descrizione</span></div>").Template("<h3>#: data.Item #</h3><p>#: data.Description #</p>")//.ValueTemplate("<span>#: data.Item#</span>")
            .Placeholder("Scegli un articolo")
            .DataSource(source =>
            {
                source.Read(read =>
                {
                    read.Action("GetItem", "Ordini")
                           .Data("artForn");
                }).ServerFiltering(true);
            })
            .Events(e =>
                {
                    e.Change("change");
                })
            .AutoBind(false)
            .Filter(FilterType.Contains)
            .DataValueField("Item")
            .DataTextField("Item")
            )


          
            @Html.ValidationMessageFor(model => model.Item)



        </div>



     <div  id="ldesc"class="col-md-offset-4 col-md-8">
            @Html.Label("Descrizione Articolo")
        </div>
        
    <div class="col-md-offset-4 col-md-8">
        @(Html.Kendo().EditorFor(model=>model.Description)
        .Name("Description").Tools(tools => tools
              

              .ViewHtml()

          ).Value(@<text><p>
        Read <a href="">more details</a> 
        
       
    </p>
        </text>)



    )

        @Html.ValidationMessageFor(model => model.Description)
        </div>



        <div id="lum" class="col-md-offset-4 col-md-4">
            @Html.Label("UM")
        </div>
        <div class="col-md-offset-4 col-md-4">
            @Html.Kendo().DropDownListFor(model => model.BaseUoM).Name("BaseUoM").DataTextField("BaseUoM").DataValueField("BaseUoM").DataSource(source =>
       {
           source.Read(read =>
           {
               read.Action("GetUom", "Ordini")
                  .Data("filterUnitValue");
           }).ServerFiltering(true);

       }).Enable(false).AutoBind(false).CascadeFrom("Item")

            @Html.ValidationMessageFor(model => model.BaseUoM)
        </div>


        <div id="lpconf" class="col-md-offset-4 col-md-10">
            @Html.Label("Pezzi per confezione")
        </div>
        <div class="col-md-offset-4 col-md-10">
            @Html.Kendo().DropDownListFor(model => model.PezziConf).Name("PezziConf").DataTextField("MinimumSaleQty").DataValueField("MinimumSaleQty").DataSource(source =>
    {
        source.Read(read =>
        {
            read.Action("GetPezziConf", "Ordini")
               .Data("filterDueValue");
        }).ServerFiltering(true);

    }).Enable(false).AutoBind(false).CascadeFrom("Item")


            @Html.ValidationMessageFor(model => model.PezziConf)

        </div>

        <div id="lqty" class="col-md-offset-4 col-md-10">
            @Html.Label("Quantità")
        </div>
        <div class="col-md-offset-4 col-md-10">
            @Html.Kendo().NumericTextBoxFor(model => model.Qty).Decimals(2).Min(1).Max(99999.0).Value(1).Name("Qty")


            @Html.ValidationMessageFor(model => model.Qty)
        </div>

        <div id="lpr" class="col-md-offset-4 col-md-10">
            @Html.Label("Valore Unitario")
        </div>
        <div class="col-md-offset-4 col-md-10">
            @Html.Kendo().DropDownListFor(model => model.UnitValue).DataTextField("UnitValue").Name("UnitValue").DataValueField("UnitValue").Events(events => events.Change("OrderDetailsEdit_Price_Change")).DataSource(source =>
    {
        source.Read(read =>
        {
            read.Action("GetUnitValue", "Ordini")
               .Data("filterDueValue");
        }).ServerFiltering(true);

    }).Enable(false).AutoBind(false).CascadeFrom("Item")




            @Html.ValidationMessageFor(model => model.UnitValue)
        </div>

        <div id="lsc" class="col-md-offset-4 col-md-10">
            @Html.Label("Sconto")
        </div>
        <div class="col-md-offset-4 col-md-10">
            @Html.Kendo().DropDownListFor(model => model.DiscountFormula).Name("DiscountFormula").DataTextField("DiscountFormula").DataValueField("DiscountFormula").DataSource(source =>
       {
           source.Read(read =>
           {
               read.Action("GetDF", "Ordini")
                  .Data("filterDueValue");
           }).ServerFiltering(true);

       }).Enable(false).AutoBind(false).CascadeFrom("Item")


        </div>

        <div id="lect" class="col-md-offset-4 col-md-10">
            @Html.Label("EcoTassa")
        </div>
        <div class="col-md-offset-4 col-md-10">

            @Html.Kendo().DropDownListFor(model => model.EcoTassa).Name("EcoTassa").Value("0").DataTextField("EcoTassa").DataValueField("EcoTassa").DataSource(source =>
       {
           source.Read(read =>
           {
               read.Action("GetEcoT", "Ordini")
                  .Data("filterDueValue");
           }).ServerFiltering(true);

       }).Enable(false).AutoBind(false).CascadeFrom("Item")

        </div>

        <div id="ltaxc" class="col-md-offset-4 col-md-10">
            @Html.Label("Codice IVA")
        </div>
        <div class="col-md-offset-4 col-md-10">

            @Html.Kendo().DropDownListFor(model => model.TaxCode).Name("TaxCode").DataTextField("TaxCode").DataValueField("TaxCode").DataSource(source =>
       {
           source.Read(read =>
           {
               read.Action("GetTaxCode", "Ordini")
                  .Data("filterUnitValue");
           }).ServerFiltering(true);

       }).Enable(false).AutoBind(false).CascadeFrom("Item")

        </div>


    @section Scripts {
        @Scripts.Render("~/bundles/jqueryval")

    }

     

     

     

  2. Stefan
    Admin
    Stefan avatar
    2880 posts

    Posted 04 Oct 2017 Link to this post

    Hello, Giorgio,

    Thank you for the provided code.

    In general, it looks good, but could you please specify which fields are not correctly bound after an update, so we can inspect them more closely?

    Also, I can recommend checking our example with a custom Popup editor to observe how the model binding is done:

    http://docs.telerik.com/aspnet-mvc/helpers/grid/how-to/editing/custom-popup-editor

    Sending us a runnable example reproducing the issue is also very helpful as it will allow us to provide a suggestion best suited for it.

    Regards,
    Stefan
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top