jQWidgets Forums
jQuery UI Widgets › Forums › Grid › have a rowIndex instead row in initwidget()
Tagged: #jqwidgets-grid, grid, javascript grid, jquery grid
This topic contains 5 replies, has 3 voices, and was last updated by Hristo 7 years ago.
-
Author
-
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 therow
is a normal object withbounddata
property, so I can read all the row and another cells dynamicaly.
But ininitwidget
, which runs e.g. after sort event, therow
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 youHello ulin,
Maybe you know the “Widget Column” demo but I would like to suggest you look at it.
There hasinitwidget
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?lightBest Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.comHello,
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,
JiriHello 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 HristovjQWidgets team
http://www.jqwidgets.comHello 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.
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 thevalue
argument of theinitwidget
.
Thank you for the understanding.Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.