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

Edit Grid: Using DropDownList shows "Undefined" as the DataTextField

2 Answers 277 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Aron
Top achievements
Rank 1
Aron asked on 01 May 2013, 08:18 PM
I have had great success with your GRID widget but I am having one problem.  I am unable to get the dropDownMenu to show the possible choices, “undefined” shows up for every choice.  I looked through many threads on this topic but could not find a solution for me.

I have a workable project where you can see this problem.  
I modeled this page after your demo:  http://demos.kendoui.com/web/grid/editing-custom.html
  1. Login to site "http://life-renewal-test.org"  using ID=friend@gmail.com
  2. Psw = friend!
  3. Click "edit" near my Volunteer Offers to get to page manageVolunteerInfo.cshtml
  4. Click on Type “Fund Raising” to get the dropdownMenu choices
  5. All choices read “undefined”
The page data is sourced from:  http://life-renewal-test.org/friend/volunteerGridRead.cshtml
The dropdown data is sourced from: http://life-renewal-test.org/friend/volunteerTypeRead.cshtml

Thank you

2 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 03 May 2013, 12:17 PM
Hello Aron,

The request for the DropDownList data yields text data, and the dataSource processes each character of the string as an item, therefore getting the "undefined" text/value. You can either set the correct response header on the server (so that the client-side knows that a JSON response is returned), or hint the $.ajax method through the dataType configuration option:

  dataSource: {
     type: "json", // this is an invalid datasource type and is ignored
     transport: {
         read: {
             url: "volunteerTypeRead.cshtml",
             dataType: "json"
         }
     }
  }

Greetings,
Alex Gyoshev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Accepted
Aron
Top achievements
Rank 1
answered on 19 May 2013, 11:28 AM
Thanks for the tip.  That worked.
Basically, I added a Response.ContentType command at the server cshtml.
        Response.ContentType = "application/json";
        Response.Write(json);
        Response.End();
Tags
Grid
Asked by
Aron
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Aron
Top achievements
Rank 1
Share this question
or