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

Problem in getting value of a column for inline edit

1 Answer 80 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jayraj
Top achievements
Rank 1
Jayraj asked on 18 Mar 2013, 05:44 AM
I have a grid partial as follows:

@using (Ajax.BeginForm("DppExcpnUpdate",
"DppExcpn", new AjaxOptions
    {
        UpdateTargetId = "divDppExcpnContent"
    }))
        {       
            @(Html.Kendo().Grid(Model)
                  .Name("gridDppExcpn")
              .Columns(columns =>
              {
                  columns.Bound(item =>
item.DppExcpnUid).Hidden().Visible(false);
                  columns.Bound(p =>
p.OrglUser).Hidden().Visible(false);
                  columns.Bound(p =>
p.OrglStamp).Hidden().Visible(false);
                  columns.Bound(p =>
p.UpdtUser).Hidden().Visible(false);
                  columns.Bound(p =>
p.UpdtStamp).Hidden().Visible(false);
                  columns.Template(@<text></text>).Width(25).Title("").ClientTemplate("<div class='gridAction' param-DppExcpnUid='#=
DppExcpnUid #'></div>");
                  columns.Bound(item =>
item.EqpTyp)
                    .Title("Equipment Type")
                    .Sortable(false)
                    .Filterable(false)
                    .Width(150);
                  columns.Bound(item =>
item.DmgCd)
                    .Title("Damage Code")
                    .Sortable(false)
                    .Filterable(false)
                    .Width(120);
                  columns.Bound(item =>
item.Dscr)
                    .Title("Damage Description")
                    .Filterable(false)
                    .Sortable(false)
                    .Width(240);
                  columns.Bound(item =>
item.Rmks)
                    .Title("Remarks")
                    .Sortable(false)
                    .Filterable(false);
              })
             //.AutoBind(false)
                  .Editable(editable =>
editable.Mode(GridEditMode.InLine))
                                     .Events(e
=> e.DataBound("Mol.Mr.CONMOCodes.DppExcpn.Ux.gridDppExcpndataBound")
.Save("Mol.Mr.CONMOCodes.DppExcpn.Ux.gridDppExcpnSave"))
                 .DataSource(dataSource =>
dataSource.Ajax()
                       .Sort(sort =>
                                {
                                    sort.Add(m
=> m.LsrCode).Ascending();
                                })
                .Model(model => model.Id(p
=> p.DppExcpnUid))
                .Read(read => read.Action("DppExcpnRead",
"DppExcpn", new { lsrCode = strLsrCode }))
                                    .Create("DppExcpnCreate",
"DppExcpn")
                                    .Update("DppExcpnUpdate",
"DppExcpn")
                .Events(events =>
events.Error("Mol.Mr.CONMOCodes.DppExcpn.Ux.DppExcpnError")
.RequestEnd("Mol.Mr.CONMOCodes.DppExcpn.Ux.gridDppExcpnRequestEnd"))
             )
              .Selectable()
              .Pageable()
              .Sortable()
              .Filterable()
                  )
}

My model is like:

/// <summary>
        /// Get or set property for DmgCd property.
        /// </summary>
        /// //[Required]
        [DataMember]
        [UIHint("DmgCdEditor")]
        public string DmgCd { get; set; }

        /// <summary>
        /// Get or set property for Dscr property.
        /// </summary>
        [DataMember]
        public string Dscr { get; set; }

        /// <summary>
        /// Get or set property for Rmks property.
        /// </summary>
        [DataMember]
        //[UIHint("RemarksEditor")]
        public string Rmks { get; set; }

        /// <summary>
        /// Get or set property for EqpTyp property.
        /// </summary>
        [DataMember]
        [DisplayName("Equipment Type")]
        [UIHint("EqpTypEditor")]
        [ConcurrencyCheck]
        public string EqpTyp { get; set; }

The above editor template are :
DmgCdEditor:

@using Mol.Mr.CONMOCodes.Ux
@model string
@{
    MaxRepairAmtController ctrl = new MaxRepairAmtController();
    }
@(Html.Kendo().DropDownListFor(m => m)
          //.Name("DmgCd")
          .HtmlAttributes(new {style="width:99px;" })
                              .DataValueField("Value")
                                  .DataTextField("Text")
                                  .BindTo(ctrl.GetListData("DmgCd"))
)

EqpTypEditor:

@using Mol.Mr.CONMOCodes.Ux
@model string
@{
    MaxRepairAmtController ctrl = new MaxRepairAmtController();
    }
@(Html.Kendo().DropDownListFor(m => m)
          //.Name("EqpTyp")
          .HtmlAttributes(new {style="width:99px;" })
                              .DataValueField("Value")
                                  .DataTextField("Text")
                                  .BindTo(ctrl.GetListData("EqpTyp"))
)

Now the problem is:
My grid actually has 4 columns as :
Equipment Type
Damage Code
Damage Description
Remarks

Now on add/edit I am getting "Remarks" value always as null but if database already had value for the column then I can successfully edit it. Again, if I take out the editor templates from the grid partial then I am getting all the columns' values, but I can't take them out as all those are needed for my case.

Please help it is urgent. 

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 19 Mar 2013, 04:53 PM
Hello Jayraj,

I assume that the questions is that you are editing a nullable field with DropDownList. There are different approaches covered over the forums you can use to solve the problem. 
One of them is covered in this the code library article - by adding custom MVVM binder.

http://www.kendoui.com/code-library/grid-/binding-nullable-field-to-dropdownlist-editor-in-grid.aspx

Kind Regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Jayraj
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or