jQuery UI Widgets Forums ASP .NET MVC Unable to bind data to jqx.dataAdapter

This topic contains 6 replies, has 2 voices, and was last updated by  Hristo 1 year, 5 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author

  • Prakash
    Participant

    Hello,
    We are unable to bind data to the dataAdapter from the controller.
    We are using jQWidgets v5.3.2 (2017-Sep).
    Js code:

     var GROUPSsource =
            {
                datatype: "json",
                datafields: [
                    { name: 'OPTGROUPID', map: 'OPTGROUPID', type: 'string' },
                    { name: 'OPTGROUP', map: 'OPTGROUP', type: 'string' }
                ],
                url: "Quotes/Quoteitemoptions",
                id: "OPTGROUPID",
                data: {
                    featureClass: "P",
                    style: "full",
                    maxRows: 12
                },
                root: "ITEMGROUP"
            };
    
            dataQUOTEGroups_v1 = new $.jqx.dataAdapter(GROUPSsource,
                {
                    autoBind: true,
                    async: false,
                    loadComplete: function () {
                    },
                    formatData: function (data) {
                    }
                }
            );
    

    Controller method:

    
            public async Task<ActionResult> Quoteitemoptions()
            {
                try
                {
                    string path = _apilist.Quoteitemoptions ;
                    HttpResponseMessage response = await _WebApiService.GetJsonResponse(path);
                    string res = response.Content.ReadAsStringAsync().Result;
                    return Json(res);
                }
                catch (Exception)
                {
                    throw;
                }
            }
    

    Error message:
    Error in InitializeQUOTEITEMSGroupData: Cannot use ‘in’ operator to search for ‘length’ in {“GROUPS”:{“ITEMGROUP”:[{“OPTGROUPID”:”1″,”OPTGROUP”:”A”,”OPTTYPE”:”QUOTEITEM”},{“OPTGROUPID”:”2″,”OPTGROUP”:”B”,”OPTTYPE”:”QUOTEITEM”},{“OPTGROUPID”:”3″,”OPTGROUP”:”C”,”OPTTYPE”:”QUOTEITEM”},{“OPTGROUPID”:”4″,”OPTGROUP”:”D”,”OPTTYPE”:”QUOTEITEM”},{“OPTGROUPID”:”5″,”OPTGROUP”:”E”,”OPTTYPE”:”QUOTEITEM”},{“OPTGROUPID”:”6″,”OPTGROUP”:”F”,”OPTTYPE”:”QUOTEITEM”}]}}

    Please help! Not sure where I’m doing it wrong.
    Thank you,


    Hristo
    Participant

    Hello Prakash,

    Please, check the error message.
    I would like to suggest you set the async: true for the jqxDataAdapter.
    Because I saw your controller method is asynchronous.
    Could you provide us with more details if this does not help you?
    Also, you could take a look at some of our demos in ASP .NET MVC section and try to use it.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    https://www.jqwidgets.com


    Prakash
    Participant

    Hello Hristo,
    using async: true is not working.
    Some issue with binding of json data.!
    If you look into the error message it’s json object.
    Cannot use ‘in’ operator to search for ‘length’ in {“GROUPS”:{“ITEMGROUP”:.....

    Let me know if you need more information on this.
    Data from controller:
    {“GROUPS”:{“ITEMGROUP”:[{“OPTGROUPID”:”1″,”OPTGROUP”:”A”,”OPTTYPE”:”QUOTEITEM”},{“OPTGROUPID”:”2″,”OPTGROUP”:”B”,”OPTTYPE”:”QUOTEITEM”},{“OPTGROUPID”:”3″,”OPTGROUP”:”C”,”OPTTYPE”:”QUOTEITEM”},{“OPTGROUPID”:”4″,”OPTGROUP”:”D”,”OPTTYPE”:”QUOTEITEM”},{“OPTGROUPID”:”5″,”OPTGROUP”:”E”,”OPTTYPE”:”QUOTEITEM”},{“OPTGROUPID”:”6″,”OPTGROUP”:”F”,”OPTTYPE”:”QUOTEITEM”}]}}

    Thank you,


    Prakash
    Participant

    We are using jQWidgets v5.3.2 (2017-Sep).
    Do you think this is the issue ?


    Hristo
    Participant

    Hello defyent,

    I would like to mention that we do not provide fixes for old versions.
    For this reason, we recommend using the latest version of jQWidgets: https://www.jqwidgets.com/download/
    There is a lot of fixes and improvements from the mentioned version to now.
    If you still have trouble with this after this suggestion please provide us one simplified example of your case.
    You could contact the Technical Support Team (support@jqwidgets.com) with this.
    Also, I would like to suggest you try to check the validity of the JSON that you receive and how it bound to the DataAdapter.
    The last one I tried and it seems to work fine:

    var jsonData = "{"GROUPS":{"ITEMGROUP":[{"OPTGROUPID":"1","OPTGROUP":"A","OPTTYPE":"QUOTEITEM"},{"OPTGROUPID":"2","OPTGROUP":"B","OPTTYPE":"QUOTEITEM"},{"OPTGROUPID":"3","OPTGROUP":"C","OPTTYPE":"QUOTEITEM"},{"OPTGROUPID":"4","OPTGROUP":"D","OPTTYPE":"QUOTEITEM"},{"OPTGROUPID":"5","OPTGROUP":"E","OPTTYPE":"QUOTEITEM"},{"OPTGROUPID":"6","OPTGROUP":"F","OPTTYPE":"QUOTEITEM"}]}}";
    
    var source = {
      localData: jsonData,
      dataType: "json",
      dataFields: [{
        name: "OPTGROUPID",
        type: "number"
      }, {
        name: "OPTGROUP",
        type: "string"
      }, {
        name: "OPTTYPE",
        type: "string"
      }],
      root: "ITEMGROUP"
    };
    
    var dataAdapter = new $.jqx.dataAdapter(source, {
    	autoBind: true
    });
    
    console.log(dataAdapter.records);
    

    Best Regards,
    Hristo Hristov

    jQWidgets team
    https://www.jqwidgets.com

    • This reply was modified 1 year, 5 months ago by  Hristo.
    • This reply was modified 1 year, 5 months ago by  Hristo.

    Prakash
    Participant

    Hello Hristo,
    I have tried with latest version but not working.

    Can you please provide sample code for to how to validity of the received JSON.
    What do you mean by how it bound to the DataAdapter?

    I am able to bind data using localData. But I want to use dynamic ajax calling so that dataAdapter.binddata() atomatically get latest data.
    And if I use local data on rebind it’s using old data.

    Thank you.


    Hristo
    Participant

    Hello defyent,

    I mean to check the binding with the DataAdapter.
    To check for any other error messages.
    But it seems the binding is fine.
    The next step is to check is the same data as the hardcoded data that you use in the DataAdapter.
    Also, I would like to suggest you look at this tutorial that could be useful, too.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    https://www.jqwidgets.com

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

You must be logged in to reply to this topic.