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

Kendo Grid Inline combobox not changing value

6 Answers 581 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Adil
Top achievements
Rank 1
Iron
Veteran
Iron
Adil asked on 04 Mar 2020, 01:06 PM

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");
                    })
              )

6 Answers, 1 is accepted

Sort by
0
Aleksandar
Telerik team
answered on 06 Mar 2020, 09:42 AM

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.
0
Adil
Top achievements
Rank 1
Iron
Veteran
Iron
answered on 10 Mar 2020, 09:16 AM
My templates are in that folder from the beginning i made everything but not worked
0
Aleksandar
Telerik team
answered on 11 Mar 2020, 04:07 PM

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.
0
Adil
Top achievements
Rank 1
Iron
Veteran
Iron
answered on 23 Mar 2020, 07:33 AM

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.....

1
Accepted
Aleksandar
Telerik team
answered on 24 Mar 2020, 03:57 PM

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.
Ecosoft
Top achievements
Rank 1
commented on 03 Aug 2022, 07:39 AM

i had the same issue, and it got resolved by doing this. But when i did this, the combobox value is showing in the grid instead of text. 

Could you please guide me.?

 

0
Adil
Top achievements
Rank 1
Iron
Veteran
Iron
answered on 30 Mar 2020, 07:07 AM
Thank you Alexssander... Finally i solved my issue thank you
Tags
Grid
Asked by
Adil
Top achievements
Rank 1
Iron
Veteran
Iron
Answers by
Aleksandar
Telerik team
Adil
Top achievements
Rank 1
Iron
Veteran
Iron
Share this question
or