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

updating grid with selected text from dropdownlist

3 Answers 127 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jonas
Top achievements
Rank 1
Jonas asked on 24 Mar 2015, 08:25 AM
Hello

I have a grid containing product registrations, fetched from a table(registration) in a DB. One of the columns in the registration table is for countryName, country is stored as a FK countryID (int) in the registration table. But in the grid i'm showing the corresponding countryname. I have a popup editor for rows in the grid with a dropdowlist for chosing country, this dropdownlist fetches data from the country table with id as datavaluefield and name as datatextfield. 

The code for the country column in the grid:
columns.Bound(c => c.countryName).Width(120).Locked(true);

The code for the dropdownlist:
@(Html.Kendo().DropDownListFor(model => model.countryId)
              .HtmlAttributes(new { style = "width: 183px", required = "required" })
              .DataTextField("name")
              .DataValueField("id")
              .OptionLabel("Select country...")
              .DataSource(source =>
              {
                  source.Read(read =>
                  {
                      read.Action("GetCountries", "Home");
                  });
              })
            )

As you can see the column in the grid is mapped to countryName and the dropdownlist is mapped to countryId. This means changes made in the dropdownlist doesn't get updated in the grid. How can I update the countryName cell in the grid with the selectedTextvalue from the dropdownlist?

/Jonas

3 Answers, 1 is accepted

Sort by
0
Accepted
Boyan Dimitrov
Telerik team
answered on 25 Mar 2015, 04:25 PM

Hello Jonas,

An easy and convenient way of achieving such functionality would be using the approach shown in the Grid / ForeignKey column demo. You can edit the category using a drop down list. 

Regards,
Boyan Dimitrov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Jonas
Top achievements
Rank 1
answered on 26 Mar 2015, 01:13 PM
Solved it by following this set of videos:

Getting Started With The ASP.NET MVC Wrappers For Kendo UI

BR
Jonas
0
Boyan Dimitrov
Telerik team
answered on 26 Mar 2015, 01:48 PM

Hello Jonas,

I am glad to hear that everything works fine now. 

Regards,
Boyan Dimitrov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
Grid
Asked by
Jonas
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Jonas
Top achievements
Rank 1
Share this question
or