jQuery UI Widgets Forums Grid The loadedData property

This topic contains 6 replies, has 3 voices, and was last updated by  fritzfrancis 9 years, 3 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • The loadedData property #77466

    fritzfrancis
    Participant

    Hello,

    My application recently required me to be able to access the original JSON response that my jqxGrid’s data adapter received in the AJAX call. It wasn’t until I discovered the source object’s loadedData property that I was able to achieve my goal.

    Here is an example of my selector:
    $("#jqxGrid").jqxGrid("source").loadedData

    As I was unable to find anything in the jqxGrid or jqxAdapter documentation that mentions the loadedData property, I’d like to know if there’s a reason I should not be using it, or if there’s some other way to get to that data through an officially supported method.

    If there are no drawbacks to using the loadedData property, perhaps some documentation should be added so that others can utilize this very helpful property.

    Regards,
    Fritz Francis

    The loadedData property #77473

    Peter Stoev
    Keymaster

    Hi fritzfrancis,

    I would suggest you to do not use internal properties. The dataAdapter’s records property which is an Array is enough for any use of jqxDataAdapter.

    Best Regards,
    Peter Stoev

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

    The loadedData property #77509

    fritzfrancis
    Participant

    Hi Peter,

    In my case, using the records property was not enough because my dataAdapter’s source URL returns a JSON object that contains more than just an array of my grid data. For instance, let’s say my dataAdapter’s source URL is “/Home/GridJSON”. It returns a JSON object that’s shaped like this:

    {
        ClickOpensNewTab: bool,
        GridData: Array[n],
        IsSuccessful: bool,
        StatusMessage: ""
    }

    As you can see, the JSON object itself isn’t what the grid binds to. Rather, the GridData property inside the JSON object is what it binds to. So in this case, loadedData and records will not be identical. The loadedData property will give me the whole JSON object, whereas the records property will only give me the array.

    This brings up a question: how does the jqxDataAdapter/jqxGrid know to use my GridData array, rather than trying to bind to the whole JSON object and failing? Does it just look for the first array inside the JSON and use that?

    Regards,
    Fritz Francis

    The loadedData property #77513

    admin
    Keymaster

    Hi fritzfrancis,

    There is mapping, record and root settings in the adapter’s source object which point where the data array is.

    Best Regards,
    Peter Stoev

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

    The loadedData property #77514

    fritzfrancis
    Participant

    Thanks for your quick reply.

    I’m not quite sure how those properties relate to the question, because in my object, both record and root are blank strings. So I’m still wondering how it knows to use the GridData array rather then the whole JSON object.

    The loadedData property #77546

    Peter Stoev
    Keymaster

    Hi fritzfrancis,

    It knows what is Array and what is not.

    Best Regards,
    Peter Stoev

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

    The loadedData property #77573

    fritzfrancis
    Participant

    That makes sense. So, if it has the ability to look at only the array inside the JSON object, then putting extra information in the JSON object and referring to it using loadedData seems like a very standard use case. I think other developers would find this functionality very useful, and that loadedData is an excellent candidate to be made into an officially documented property.

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

You must be logged in to reply to this topic.