Kendo Grid Inline combobox not changing value

7 posts, 1 answers
  1. Adil
    Adil avatar
    26 posts
    Member since:
    Mar 2014

    Posted 04 Mar 2020 Link to this post

    I have kendo mvc grid with inline edition. I want to edit my values in grid but when i click on combobox value and change it. It's not changing row value return old existing value
    How can i solve this?
    Here my grid and Templates

    @(Html.Kendo().Grid<MockUpForeNet.Controllers.CardDetailController.Limits>()
            .Name("limitgrid").AutoBind(true)
            .DataSource(dataBinding => dataBinding.Ajax()
            .Read("GridLimitBinding", "CardDetail",new { rule = rule }).Update("UpdateLimit", "Transaction")
            .Model(keys =>
            {
                keys.Id(c => c.Id);
                keys.Field(c => c.Id).Editable(false);
                keys.Field("DurationType", typeof(string)).Editable(true);
                keys.Field("DurationValue", typeof(string)).Editable(true);
                keys.Field("ValueType", typeof(string)).Editable(true);
                keys.Field("MaxValue", typeof(string)).Editable(true);
     
            }).Batch(true).ServerOperation(false)
            )
            .Events(e => e.DataBound("hidecolumn1"))
            .Editable(editing => editing.Mode(Kendo.Mvc.UI.GridEditMode.InCell))
            .ToolBar(commands =>
            {
                commands.Create().Text(" ");
                commands.Save().SaveText(" ").CancelText(" ");
            })
            .Columns(columns =>
            {
                columns.Bound(e => e.MaxValue).Width(200).Title("Limit").ClientTemplate("#= ValueType == 'Amount' ? Row(MaxValue) : RowLiters(MaxValue) #");
                columns.Bound(e => e.ValueType).Width(200).Title("Type").EditorTemplateName("ValueType");
                columns.Bound(e => e.DurationValue).Width(200).Title("Duration");
                columns.Bound(e => e.DurationType).Width(200).Title("Duration Type").EditorTemplateName("DurationType");
                columns.Bound(e => e.Id).Visible(false);
                columns.Bound(e => e.Id).Width(80).ClientTemplate("<img src='../../assets/images/icons/delete.svg' id='#=Id#' />").Filterable(false).IncludeInMenu(false).Title(" ");
            })
            //.Selectable()
            .Sortable()
            .Navigatable(configurator => configurator.Enabled(true))
     
     
     
             ///My editor templates
              @(Html.Kendo().ComboBox()
                    .Name("cbvaltype")
                    .Items(i =>
                    {
                        i.Add().Text("Quantity").Value("Quantity");
                        i.Add().Text("Amount").Value("Amount");
                    })
                )
     
                @(Html.Kendo().ComboBox()
                        .Name("cmbdurationtype")
                        .Items(i =>
                            {
                            i.Add().Text("Hour").Value("Hour");
                            i.Add().Text("Day").Value("Day");
                            i.Add().Text("Week").Value("Week");
                            i.Add().Text("Month").Value("Month");
                            i.Add().Text("Year").Value("Year");
                        })
                  )
  2. Aleksandar
    Admin
    Aleksandar avatar
    242 posts

    Posted 06 Mar 2020 Link to this post

    Hello Adil,

    I would suggest checking article on creating custom editors along with the Custom Editor demo we have for the Grid.

    You need to create a CustomEditor that should be located in the  \Views\Shared\EditorTemplates. To utilize the provided CustomEditor you will also need to decorate the Model field with a [UIHint("CustomEditor")] attribute. If the application logic supports creation of new items specify a default value in the model configuration that will be used initially when creating an item.

    I hope this helps.

    Regards,
    Aleksandar
    Progress Telerik

    Get quickly onboarded and successful with your Telerik UI for ASP.NET MVC with the dedicated Virtual Classroom technical training, available to all active customers.
  3. Adil
    Adil avatar
    26 posts
    Member since:
    Mar 2014

    Posted 10 Mar 2020 in reply to Aleksandar Link to this post

    My templates are in that folder from the beginning i made everything but not worked
  4. Aleksandar
    Admin
    Aleksandar avatar
    242 posts

    Posted 11 Mar 2020 Link to this post

    Hi Adil,

    Attached you will find a demo solution where a ComboBox is implemented as a custom editor for the Grid, based on the approach demonstrated in the Demo section.

    Could you please update the sample so the observed behavior is reproducible and send it back to me for further review? This way I could review and provide further guidance.

    Regards,
    Aleksandar
    Progress Telerik

    Get quickly onboarded and successful with your Telerik UI for ASP.NET MVC with the dedicated Virtual Classroom technical training, available to all active customers.
  5. Adil
    Adil avatar
    26 posts
    Member since:
    Mar 2014

    Posted 23 Mar 2020 in reply to Aleksandar Link to this post

    Hi Aleksandar,

    Beleive me i made everything... all steps but still not working... This is my grid

    @(Html.Kendo().Grid<MockUpForeNet.Controllers.CardDetailController.Limits>()
                .Name("limitgrid").AutoBind(true)
                .DataSource(dataBinding => dataBinding.Ajax()
                .Read("GridLimitBinding", "CardDetail",new { rule = rule }).Update("UpdateLimit", "CardDetail")
                .Model(keys =>
                {
                    keys.Id(c => c.Id);
                    keys.Field(c => c.Id).Editable(false);
                    keys.Field("DurationType", typeof(string)).Editable(true);
                    keys.Field("DurationValue", typeof(string)).Editable(true);
                    keys.Field("ValueType", typeof(string)).Editable(true);
                    keys.Field("MaxValue", typeof(string)).Editable(true);
     
                }).Batch(true).ServerOperation(false)
                )
                .Events(e => e.DataBound("hidecolumn1"))
                .Editable(editing => editing.Mode(Kendo.Mvc.UI.GridEditMode.InCell))
                .ToolBar(commands =>
                {
                    commands.Save().SaveText(" ").CancelText(" ");
                })
                .Columns(columns =>
                {
                    columns.Bound(e => e.MaxValue).Width(200).Title("Limit").ClientTemplate("#= ValueType == 'Amount' ? Row(MaxValue) : RowLiters(MaxValue) #");
                    columns.Bound(e => e.ValueType).Width(200).Title("Type").EditorTemplateName("ValueType");
                    columns.Bound(e => e.DurationValue).Width(200).Title("Duration");
                    columns.Bound(e => e.DurationType).Width(200).Title("Duration Type").EditorTemplateName("DurationType");
                    columns.Bound(e => e.Id).Visible(false);
                    columns.Bound(e => e.Id).Width(80).ClientTemplate("<img src='../../assets/images/icons/delete.svg' id='#=Id#' />").Filterable(false).IncludeInMenu(false).Title(" ");
                })
                .Sortable()
                .Navigatable(configurator => configurator.Enabled(true))
        )

     

    This is my editor

    @(Html.Kendo().DropDownList()
        .Name("cbvaltype").OptionLabel("-Select-").ValuePrimitive(true)
        .Items(i =>
        {
            i.Add().Text("Quantity").Value("Quantity");
            i.Add().Text("Amount").Value("Amount");
        })
    )

     

    And this is my controller..

    public class Limits
            {
                public int Id { get; set; }
                public string DurationType { get; set; }
                public string DurationValue { get; set; }
                public string ValueType { get; set; }
                public string MaxValue { get; set; }
            }
     
     public ActionResult GridLimitBinding([DataSourceRequest]DataSourceRequest request, string rule)
            {
                var result = (from a in test.MgCFraud
                                            where a.CfdCfeId == rulelimitid
                                            select a).FirstOrDefault();
     
                List<Limits> listLimits = new List<Limits>();
                if (result != null)
                {
                    Limits d = new Limits();
                    d.Id = resultMgCardFraudDet.CfdIdent;
                    d.DurationType = result.CfdDurTyp;
                    d.DurationValue = result.CfdDurVal;
                    d.ValueType = resultCfdMaxTyp;
                    d.MaxValue = result.CfdMaxVal;
                    listLimits.Add(d);
                }
                else
                {
                    Limits d = new Limits();
                    d.Id = 0;
                    d.DurationType = "";
                    d.DurationValue = "";
                    d.ValueType = "";
                    d.MaxValue = "";
                    listLimits.Add(d);
                }
                return Json(listLimits.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
            }

     

    Here my detail please help me i stucked on this.....

  6. Answer
    Aleksandar
    Admin
    Aleksandar avatar
    242 posts

    Posted 24 Mar 2020 Link to this post

    Hello Adil,

    I would suggest updating the Editor with Widget[For] configuration. This way you would ensure proper model binding. Currently the name of the DropDownList is set to "cbvaltype", but the Grid does not have a column with the same field name.

    @(Html.Kendo().DropDownListFor(m => m)
        .OptionLabel("-Select-").ValuePrimitive(true)
        .Items(i =>
        {
            i.Add().Text("Quantity").Value("Quantity");
            i.Add().Text("Amount").Value("Amount");
        })
    )

    Give this suggestion a try and let me know if the issue is resolved. If not it would be helpful if you could update the previously sent sample so the issue is reproducible. This would allow me to debug locally and investigate the issue further.

    Regards,
    Aleksandar
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
  7. Adil
    Adil avatar
    26 posts
    Member since:
    Mar 2014

    Posted 30 Mar 2020 in reply to Aleksandar Link to this post

    Thank you Alexssander... Finally i solved my issue thank you
Back to Top