jQuery UI Widgets Forums Grid Dynamically creating columns using json issue with cellsrenderer

This topic contains 4 replies, has 3 voices, and was last updated by  ganeshan_75 9 years, 8 months ago.

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

  • milap.shah
    Member

    Hi,

    I have a WCF service which returns JSON string for the columns that I need to show in my grid. I also need to use cellsrenderer method for these columns. Now cellsrenderer method doesn’t allow doublequotes when specifying the functionname for example “cellsrenderer”:”cellsrenderer” doesn’t work. It has to be “cellsrenderer”: cellsrenderer.

    Now – the issue is that I use .parseJSON when binding the data returned by my service to set the columns property but it throws an error when I don’t have doublequotes for any element. This makes this solution impossible to implement. Is there any way you can suggest me to fix this issue?


    Peter Stoev
    Keymaster

    Hi milap.shah,

    It will not allow “cellsrenderer” defined like that because the expected setting value is a Function, not a String. If you wish, after loading your JSON, you can parse it to remove the double quotes where it is necessary.

    Best Regards,
    Peter Stoev

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


    ganeshan_75
    Participant

    Dear Peter,

    I got stuck with the same issue. Could you help to remove the double quotes after loading JSON. I tried different ways and it errors saying “TypeError: f.cellsrenderer is not a function”.


    Peter Stoev
    Keymaster

    Hi ganeshan_75,

    The expected value is Function which means that you can use only a Function. If you set it to something else, it should not work.

    Best Regards,
    Peter Stoev

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


    ganeshan_75
    Participant

    Dear Peter,

    I guess I haven’t explained you the problem well. I understand that I have to pass a function to the cellsrenderer:. The problem is JQXGrid columns value should be a JSON array. I haven’t seen any examples in your demos that you pass that array itself as a variable. All the demos I have seem are hardcoded values of the array.

    In my scenario I have to build that array in a variable. Finally that variable will have something like this

    var columnsAsString = [{“text”:”LinkTitleNoMenu”,”datafield”:”LinkTitleNoMenu”,”width”:”250″,”cellsrenderer”:”linkrenderer”}]. If I pass this the code won’t work. It will expect something like this var columnsAsString = [{“text”:”LinkTitleNoMenu”,”datafield”:”LinkTitleNoMenu”,”width”:”250″,”cellsrenderer”: linkrenderer }]. How do I get rid of the double quotes from the function name (linkrenderer) within the Jason string. If I do then the serialization fails at $.parseJSON to convert them into an array before I pass it to the JQXGrid function columns.

    I hope this is a bug in dynamic rendering of columns to this JQXGrid. If you can find a solution to get around this issue, that would be highly appreciated.

    Thanks

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

You must be logged in to reply to this topic.