Hi all,
I would like to know how I could get/ set the css class of a particular cell in JavaScript? Thanks.
+1 Feature Request!
{ headerText: "Product ID", key: "ProductID", dataType: "number", cssClass: "my_custom_classname" }
{ headerText:
"Product ID"
, key:
"ProductID"
, dataType:
"number", cssClass: "my_custom_classname"
}
Is there really no way to configure custom class names for the table columns where you define the column array for a new grid? Seems like this would be easy, and would save MUCHO clumsy hacking around using column indexes to assign css classes after the grid is rendered...?
},
Hello Aschoi,
You can get the td element from the ui element like below:
ui.owner.element.find("tr td:nth-child(4)").css("text-align", "center");
Please let me know if I can provide any further assistance regarding this matter.
Internally, we have created a JavaScript cell object wrapper to wrap a cell. Right now, we would like to add a css property to this cell object that represents the class of the td element of the cell. Currently, I do not know how to get to the class of a td element from the ui element in a EditCellStarting event. I tried to use something like $(ui.editor.parent()).closest("td").ClassName but not working. Could you please help? thanks.
Hello aschoi,
You can get a particular cell by the row and column indices using the cellAt method:
var cell = $('#grid1').igGrid('cellAt', 1, 1);
Then you can get/set the class like this:
var class = $(cell).attr('class');
$(cell).addClass('red');
Please let me know if you have any other questions.