1

Hi I'm doing my first app mobile using telerik appBuilder and I can't get the Kendo datasource to work with a dropdown list.

The result of my webservices is below but I can't get the correct data-bind for that result.

{"d":[{"id":2209,"nom":"Test 1"},{"id":23608,"nom":"Test 2"},{"id":24061,"nom":"Test 3"},{"id":24741,"nom":"Test 4"},{"id":27347,"nom":"Test 5"}]}

Pls, any ideas? Thanks a lot.

/* product.html*/
<div id="product" data-role = "view"
         data-layout = "sharedlayout" data-model="app.productService.viewModel">                              
    <div class="view-content">
       <form >
           <div data-role="listview" data-style="inset">
             <div>
                Products:
                    <select id="product" data-role="dropdownlist"
                            data-bind="source: productsdataSource " 
                            data-text-field="id" 
                            data-value-field="product">
                        <option value="0"> </option>  
                    </select>
             </div>
          </div>
       </form>
    </div>
</div>   

ProductViewModel.js

(function (global) 
{
    var ProductsViewModel,
        app = global.app = global.app || {};

    ProductsViewModel = kendo.data.ObservableObject.extend (
    {
        getProducts: function() {
            var dataSource = new kendo.data.DataSource({
                transport: {
                    read: {
                        url: "urlexample",
                        type:"post",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json"
                    }
                },
                schema: {
                    data: "d" 
                },
                type: 'json'
            });

        }
    });
    app.productService = { viewModel: new ProductsViewModel() };
})(window);
user3783733
  • 43
  • 1
  • 5

1 Answers1

5

I'm not sure exactly where your problem lies, but i've got a few ideas...

  1. Why are you extending the observable? Why not just use kendo.observable({})?
  2. Your viewModel is returning a function, not an object which is what Kendo UI would be expecting.

I think you might be over-complicating this slightly. I've put together a dead simple example...

http://plnkr.co/edit/T41nZqZNLqtOTfjG8upK?p=preview

Might I also suggest that you drop the data-role="dropdownlist"? Mobile devices have their own select list implementations and this way you can use the native select ability on the device.

Burke Holland
  • 2,325
  • 1
  • 22
  • 33