jQWidgets Forums

jQuery UI Widgets Forums Grid have a rowIndex instead row in initwidget()

This topic contains 5 replies, has 3 voices, and was last updated by  Hristo 7 years ago.

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

  • ulin
    Participant

    Hi team,
    I have a grid which is updated from the server with virtual mode.
    I use a widget for cell of my grid like this:

    {
        text: 'Mac',
        datafield: 'mac',
        width: 140,
        initwidget: (row, column, value, html) => (createEditDialogCell(row, column, value, html)),
        createwidget: (row, column, value, html) => (createEditDialogCell(row, column, value, html))
    },

    And here is cell function:

    function createEditDialogCell (row, column, cellValue, html) {
        console.log(row);
        const item = row.bounddata;
        const element =  $('<a>${item.foo ? "hello": "item.greeting"}</a>');
        $(html).add(element)
    }

    And in createwidget which runs only the first time the row is a normal object with bounddata property, so I can read all the row and another cells dynamicaly.
    But in initwidget, which runs e.g. after sort event, the row is just the row’s index, simple number (0,1,2…) without information about the row.
    So how can I get the information like row.bounddata in this case?
    Thank you


    Hristo
    Participant

    Hello ulin,

    Maybe you know the “Widget Column” demo but I would like to suggest you look at it.
    There has initwidget callback function which is called when a widget in a cell needs to be updated.
    Also, if you want only to add a hyperlink to a column, please, take a look at this example:
    http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/customcolumn.htm?light

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com


    jirih
    Participant

    Hello,
    unfortunately, the reply does not answer the question.

    So how can I get the information like row.bounddata in this case?

    The demo does not handle the “row” at all.

    In versions prior to 4.1.0, it was possible to do it. But then the signature of the callback function changed.

    Best regards,
    Jiri


    Hristo
    Participant

    Hello Jiri,

    Could you clarify it? What you mean by The demo does not handle the "row" at all.?
    We recommend using the latest version of jQWidgets: http://www.jqwidgets.com/download/
    Could you provide us a small simple example that demonstrates your issue?

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com


    jirih
    Participant

    Hello Hristo,

    the demo you mentioned on June 26, 2017 does not use the initwdget callback. For the original question, it is quite irrelevant.

    Nevermind. The question is still the same. Earlier (prior to 4.1.0), this callback was called with an object as the row parameter. It was possible to get, for example row.bounddata inside the callback. In later versions, this callback is called with a number as the row parameter. The bounddata is not accessible anymore.

    initwidget: function (row, column, value, htmlElement) {
         console.debug(row.bounddata);
     }

    It is needed when the widget is initialized in a context of the rest of the row.


    Hristo
    Participant

    Hello Jiri,

    The design is on this callbacks is on that way.
    I would suggest you one alternative to add in this column datafield ID of the record on that way you will have the relevant reference on the value argument of the initwidget.
    Thank you for the understanding.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

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

You must be logged in to reply to this topic.