jQWidgets Forums
jQuery UI Widgets › Forums › Grid › How to get row data from the createwidget column's callback function?
Tagged: jqxGrid Grid rowdata
This topic contains 8 replies, has 2 voices, and was last updated by Ivo Zhulev 9 years, 2 months ago.
-
Author
-
March 18, 2016 at 5:32 pm How to get row data from the createwidget column's callback function? #82641
I’m trying to create a jqxButton inside a jqxGrid cell in the following way:
source: new $.jqx.dataAdapter({ ... datafields: [ { name: "id", type: "int" }, { name: "firstName", type: "string" }, ... ] ... columns: [ { text: "Actions", datafield: "actions", width: 100, createwidget: function (row, column, value, htmlElement) { var button = $("<button>Show data</button>"); $(htmlElement).append(button); button.jqxButton({}); button.click(function () { var rowdata = $("#grid").jqxGrid("getrowdata", ???); // or $("#grid").jqxGrid("getrowdatabyid", ???); alert("id = " + rowdata.id + ", first name = " + rowdata.firstName); }); }, initwidget: function (row, column, value, htmlElement) { } }
But I have no idea of how to pass the required arguments to the getrowdata function. Is it even possible?
March 21, 2016 at 8:18 am How to get row data from the createwidget column's callback function? #82656Hi trying,
Here you can see how to do that:
https://www.jseditor.io/?key=createwidget-button-callbackBest Regards,
IvojQWidgets Team
http://www.jqwidgets.com/March 21, 2016 at 8:38 am How to get row data from the createwidget column's callback function? #82658Hi Ivo,
Your solution doesn’t work. You have used ‘row.boundindex’ in your example, but this value is duplicated for different rows. So it shows wrong data.
Try to click ‘Show data’ in your example on some row which index is 17 for example:
https://www.jseditor.io/?key=createwidget-button-callbackMarch 22, 2016 at 6:30 am How to get row data from the createwidget column's callback function? #82705Maybe there is another function which I can use to create a widget with access to row data? It is very bad that I can’t create even a simple jqxButton in such a way.
Your ‘cellsrenderer’ function doesn’t allow that because it expects a raw markup to be returned.March 22, 2016 at 8:12 am How to get row data from the createwidget column's callback function? #82712Hi trying,
You will find my demo link updated. Create the button directly in another column (columntype: ‘button’).
Best Regards,
Ivo
jQWidgets Team
http://www.jqwidgets.com/March 23, 2016 at 8:10 am How to get row data from the createwidget column's callback function? #82745Hi Ivo,
But what about two or three buttons (or some complex widget containing few more widgets, etc.)?
I have simplified my example to make my question cleaner. It’s not about how to create a button, which can handle click events, but how to get row data when creating custom widgets in jqxGrid cells (in my case there may be different widgets, or no widgets at all, depending on the value of the row).
Why there is no access to the row at widget creation time? Why ‘cellsrenderer’ has this parameter and ‘createwidget’ has not?March 23, 2016 at 9:45 am How to get row data from the createwidget column's callback function? #82756Hi trying,
Please take a look at this demo:
http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/customwidgetscolumn.htm?lightBest Regards,
IvojQWidgets Team
http://www.jqwidgets.com/March 23, 2016 at 3:15 pm How to get row data from the createwidget column's callback function? #82773Hi Ivo,
There is access to the only one field per column in that demo:
columns: [ { text: 'Picture', datafield: 'firstname', width: 100, createwidget: function (row, column, value, htmlElement) { // 'value' is the value of the 'firstname' field
There is no means to access the whole row.
March 24, 2016 at 10:45 am How to get row data from the createwidget column's callback function? #82795Hi trying,
You can get the row identifier from the row argument. Then use ‘getrowdata’.
Best Regards,
IvojQWidgets Team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.