JSON Data Binding Problem

4 posts, 0 answers
  1. Charlie
    Charlie avatar
    4 posts
    Member since:
    Jun 2012

    Posted 23 Jun 2012 Link to this post


    Just sampling your UI and it seems to be just what I am after. I have tried as the first project to use a combo box. Firstly I got the box working using your example on my site, now I am trying to bind a JSON data source to it.

    the box initializes OK, but the values are filled with "undefined".

    The code used to start the box is as follows:

    <script type="text/javascript">
    $(document).ready(function() {
            index: 0,
            dataTextField: "name",
            dataValueField: "value",
            filter: "q",
            dataSource: {
                type: "json",
                serverFiltering: true,
                serverPaging: true,
                pageSize: 20,
                transport: {
                    read: "http://www.xxxxxxxxxx.net/kendo_getjson5.php"

    The data being returned by the script is as below. i am not sure what the top level element in the JSON should be>? I set it to dataSource? Maybe this is the problem?
    Also my script accepts a query string with q= , so the filter should be set to q?

    Also its not reading cross domain, its all on the same domain, so json is the correct type?

    {"dataSource":[ {"value":"1366","name":"TAD1341GE "},{"value":"1367","name":"TAD1342GE "},{"value":"1368","name":"TAD1343GE "},{"value":"1369","name":"TAD1344GE "},{"value":"1370","name":"TAD1345GE "},{"value":"943","name":"TAD1640GE "},{"value":"944","name":"TAD1641GE "},{"value":"945","name":"TAD1642GE "},{"value":"1254","name":"TAD531GE "},{"value":"1255","name":"TAD532GE "}]}

    Regards and TIA


    I have checked my datasournce with JSONLint to make sure its valid.

  2. Charlie
    Charlie avatar
    4 posts
    Member since:
    Jun 2012

    Posted 23 Jun 2012 Link to this post

    I am half way there from spotting another forum reply. I removed the top level element in my JSON and set the content type within the PHP script to Content-Type: application/json;

    It now loads the first fields. When I type however, it isn't updating with another call to the server on the q= variable I need?

    I can set the name of this variable to something else if I need to, thats no problem.

    How can I get it to update as I type?

    NB The script is returning only 10 at the start, do i need it to return more?



  3. Henk Jelt
    Henk Jelt avatar
    19 posts
    Member since:
    Jun 2012

    Posted 04 Jul 2012 Link to this post

    Hi Charlie

    I am far from an expert but from my browsing this forum I learnt that "type: json" should be "dataType: jsonp", and that this should be declared within the transport part.

    maybe this helps?

    Henk Jelt
  4. James Shelton-Agar
    James Shelton-Agar avatar
    108 posts
    Member since:
    May 2008

    Posted 04 Jul 2012 Link to this post

    as described in documentation http://www.kendoui.com/documentation/framework/datasource/overview.aspx 

    according to your json structure, you probably need 
     schema: {
    // the data which the data source will be bound to is in the "results" field
    : "datasource"

    in your datasource definition
Back to Top