Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yep, the problem was with the JSON format I was sending from the controller. I am using a 3rd party web service (based on <a href="http://servicestack.net/" rel="nofollow">ServiceStack</a>). In the controller I was 'reading' the web response in a string (which was a JSON string), and pass it further. The problem was that the JSON string returned was between " ", and somehow the dataSource cannot handle it.</p> <p>So, my solution was based on your example above: I created a model, a collection and I returned the collection.</p> <p>Result: everything worked perfect. The JSON returned was no longer between " " and the dataSource object was initialized properly.</p> <p>Here is the code:</p> <p><strong>ClientiController.cs</strong></p> <pre><code>public class ClientiController : Controller { public JsonResult Index() { StreamReader sr = null; string json = string.Empty; try { WebRequest request = WebRequest.Create("urlGoesHere"); using (WebResponse response = request.GetResponse()) { sr = new StreamReader(response.GetResponseStream(), true); json = sr.ReadToEnd(); } } catch { return Json("", JsonRequestBehavior.AllowGet); } JavaScriptSerializer serializer = new JavaScriptSerializer(); ClientiCollection collection = serializer.Deserialize&lt;ClientiCollection&gt;(json); return Json(collection, JsonRequestBehavior.AllowGet); } } </code></pre> <p><strong>Client.cs</strong></p> <pre><code>public class Client { public string ID { get; set; } public string RAGIONE_SOCIALE { get; set; } } </code></pre> <p><strong>ClientiCollection.cs</strong></p> <pre><code>public class ClientiCollection { public IEnumerable&lt;Client&gt; ClientiList { get; set; } } </code></pre> <p><strong>HTML</strong></p> <pre><code>&lt;input id="kendoCboClienti" /&gt; &lt;script type="text/javascript"&gt; $(document).ready(function () { var clientiDataSource = new kendo.data.DataSource({ transport: { read: { url: "/Clienti/", dataType: "json" } }, schema: { data: "ClientiList" } }); $("#kendoCboClienti").kendoComboBox({ dataTextField: "RAGIONE_SOCIALE", dataValueField: "ID", dataSource: clientiDataSource, }); }); &lt;/script&gt; </code></pre> <p>However, I have ~8000 records to be displayed and the combobox it's a bit slow (~1.5 sec on opening). I'm not sure if I could somehow improve the response of it, without modifying the server in any way.</p> <p>P.S. Thanks a lot, Igorrious!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload