Dropdown list in a Kendo grid with inline editing is not working and storing blanks

1 Answer 158 Views
DropDownList Grid Template
Saurabh
Top achievements
Rank 1
Iron
Saurabh asked on 03 Aug 2023, 06:21 PM

Hi,

I am working on a grid having inline edit functionality.  I am trying to create a dropdown which display a list of persons, however, I want to save the email id of the person in our backend SQL DB.

I am trying to implement this with editor template approach -

I have tried the below code -

Grid:

columns.Bound(mm => mm.Person).Title("Assigned To").EditorTemplateName("PersonList").HeaderHtmlAttributes(new { style = "white-space: normal" });

PersonList.chstml

@(Html.Kendo()
            .DropDownList()
            .Filter("contains")
            .Name("Person")
            .DataTextField("Name")
            .DataValueField("Email")
            .DataSource(dataSource =>
            {
                dataSource.Read(read => read.Action("GetPeopleByArea", "Common").Data("getPeopleByArea"))
                .ServerFiltering(true);
            })
            //.HtmlAttributes(new { required = "required", data_required_msg = "Select Person Name", style = "width: 100px" })
            .ValuePrimitive(true)
            .AutoWidth(true)
            .OptionLabel("-- Please Select --")            
    )

 

function getPeopleByArea() {
        var grid = $("#Grid").data("kendoGrid");
        var dataItem = grid.dataItem("tr.k-grid-edit-row");
        return {
            Area: dataItem.Area
        };
    }

When I edit the grid the dropdown work list works fine and it displays the filtered list of people as expected.  However, Instead of the email id the record is getting updated with Null or blanks in the backend table.

However, this approach works fine if I do not use getPeopleByArea function to filter the area based on certain conditions and use a different controller function to get the whole list.

Also, if I am using  .DataTextField("Name") and  .DataValueField("ID"), ID is getting stored and same is getting displayed on the grid instead of the Name.

What am I doing wrong here ? Can anyone please suggest.

Please let me know if you have any questions.

 

 

Thanks

Saurabh

 

Saurabh
Top achievements
Rank 1
Iron
commented on 04 Aug 2023, 03:07 PM

I am still struggling with this issue.  Any suggestions ?

1 Answer, 1 is accepted

Sort by
0
Accepted
Saurabh
Top achievements
Rank 1
Iron
answered on 07 Aug 2023, 08:29 PM

I able to figure it out.  It was backend code issue and the sql stored procedure was returning the EmailId column.  It is working perfectly fine now.

Thanks.

Tags
DropDownList Grid Template
Asked by
Saurabh
Top achievements
Rank 1
Iron
Answers by
Saurabh
Top achievements
Rank 1
Iron
Share this question
or