Problem in getting value of a column for inline edit

2 posts, 0 answers
  1. Jayraj
    Jayraj avatar
    2 posts
    Member since:
    Aug 2012

    Posted 18 Mar 2013 Link to this post

    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. 
  2. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 19 Mar 2013 Link to this post

    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!
Back to Top