updating grid with selected text from dropdownlist

4 posts, 1 answers
  1. Jonas
    Jonas avatar
    42 posts
    Member since:
    Oct 2014

    Posted 24 Mar 2015 Link to this post

    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
  2. Answer
    Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    2062 posts

    Posted 25 Mar 2015 Link to this post

    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.

     
  3. Jonas
    Jonas avatar
    42 posts
    Member since:
    Oct 2014

    Posted 26 Mar 2015 in reply to Boyan Dimitrov Link to this post

    Solved it by following this set of videos:

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

    BR
    Jonas
  4. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    2062 posts

    Posted 26 Mar 2015 Link to this post

    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.

     
Back to Top