jQuery UI Widgets Forums Plugins Data Adapter DataAdapter and 2 jqxComboBox

This topic contains 2 replies, has 2 voices, and was last updated by  fernando60 9 years, 5 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • DataAdapter and 2 jqxComboBox #69309

    fernando60
    Participant

    Welcome from France,
    I’m using jqWidget in a Microsoft Asp.Net Mvc project.
    I have a problem using 2 jqxCombobox. The second one is filled when the first one is changed.
    Here is my code :

    
     // LISTES
            var sourceListe =
            {
                datatype: "json",
                datafields: [
                    { name: 'ListeId' },
                    { name: 'Libelle' }
                ],
                url: '/home/GetListes',
                async: false
            };
            var dataAdapterListes = new $.jqx.dataAdapter(sourceListe);
            // Create a jqxComboBox
            $("#jqxListes").jqxComboBox({ selectedIndex: 0, source: dataAdapterListes, displayMember: "Libelle", valueMember: "ListeId", width: 200, height: 25 });
            // trigger the select event.
            $("#jqxListes").on('select', function (event) {
                if (event.args) {
                    var item = event.args.item;
                    if (item) {
                       
                        var sourceTitres =
                           {
                               datatype: "json",
                               datafields: [
                                   { name: 'TitreId' },
                                   { name: 'Libelle' }
                               ],
                               url: '/home/GetTitres/' + item.value,
                               async: false
                           };
                        var dataAdapterTitres = new $.jqx.dataAdapter(sourceTitres);
                        // Create a jqxComboBox
                        //debugger;
                        dataAdapterTitres.dataBind();
                        debugger;
                        $("#jqxTitres").jqxComboBox({ selectedIndex: 0, source: dataAdapterTitres, displayMember: "Libelle", valueMember: "TitreId", width: 200, height: 25 });
                    }
                }
            });
    
    <div>
        <h3>Listes:</h3> <div id='jqxListes'></div>  <h3>Titres:</h3> <div id='jqxTitres'></div>
    </div>
    

    As you can see, I use two adapters. The first one is correctly filled by the ‘/home/GetListes’ (a C# method). When I change the first jqxComboBox another method is called ‘/home/GetTitres/’ + item.value (C# method which works correctly; the result is a json list with 40 answers) but my second adapter dataAdapterTitres is empty (record.length()==0).

    By advance thank you for your help on this wonderful framework.

    Fernando.

    DataAdapter and 2 jqxComboBox #69415

    Dimitar
    Participant

    Hello Fernando,

    Your code seems fine, but here are some things you can try:

    • Remove the manual call to the dataBind method – the jqxTitres combobox will automatically bind the data adapter when its source is set to it.
    • Set the async property of both sources to true.

    If the issue persists, please check if there are any errors with the data adapter’s loadError callback. For more information, please refer to the jqxDataAdapter tutorial.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    DataAdapter and 2 jqxComboBox #69786

    fernando60
    Participant

    Hello Dimitar,

    Sorry for my late answer.
    You were right : the loadError helps me to find my problem.
    IT WASN’T A JQWIDGET’S ONE !
    I had a problem in my asp.net’s controller. It was an obscure limitation about Json() function.
    To resolve it here is the answer (in C# inside my controller):

    protected override JsonResult Json(object data, string contentType, System.Text.Encoding contentEncoding, JsonRequestBehavior behavior)
    {
    return new JsonResult()
    {
    Data = data,
    ContentType = contentType,
    ContentEncoding = contentEncoding,
    JsonRequestBehavior = behavior,
    MaxJsonLength = Int32.MaxValue
    };
    }

    I hope it would be useful for someone.
    Congratulations for this wonderful javascript framework .

    Fernando.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.