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

[Solved] Dropbox in custom grid template

1 Answer 180 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dave
Top achievements
Rank 1
Dave asked on 20 Jan 2015, 04:41 AM
Hi

I'm trying to get a dropdown box in a custom popup template to populate from a datastore but can't get it to work.  If I use the default popup custom binding an editor to the data store it works, but I need to use a custom template.

Here is my code

//datastore setup
        var ds_YesNo = new kendo.data.DataSource({
            transport: {
                read: {
                    url: URL_TO_DS,
                    type: "get",
                    dataType: "json"
                }
            },
            schema: {
                data: "children",
                total: function(response) {
                    return response.paging.YesNo.count;
                }
            }
        })
        ds_YesNo.read();


The datastore returns the following back
{
"paging": {
    "YesNo": {
         "page": 1,
         "current": 2,
         "count": 2,
         "prevPage": false,
         "nextPage": false,
         "pageCount": 1,
         "order": null,
         "limit": 10,
         "options": {
              "conditions": []
         },
         "paramType": "querystring"
}
},
"children": [
         {
                  "YesNo_YesNoID": "N",
                  "YesNo_YesNoName": "No"
         },
         {
                  "YesNo_YesNoID": "Y",
                  "YesNo_YesNoName": "Yes"
         }
]
}


Then in my edit template I have this

        <div class="k-edit-field" data-container-for="Staff_Active">
            <input name="Staff_Active"
                data-bind="value:Staff_Active"
                data-value-field="YesNo_YesNoID"
                data-text-field="YesNo_YesNoName"
                data-source="ds_YesNo"
                data-role="dropdownlist" />
        </div>

but the dropbox is empty - all the other standard input text fields display fine.

Would appreciate some assistance.

Regards

Dave

1 Answer, 1 is accepted

Sort by
0
Dave
Top achievements
Rank 1
answered on 20 Jan 2015, 06:59 AM
Figured it out - had my datastore creation pasted in the wrong spot - it was inside my $(document).ready(function() - needed to be outside
Tags
Grid
Asked by
Dave
Top achievements
Rank 1
Answers by
Dave
Top achievements
Rank 1
Share this question
or