jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Vertical alignment in grid cell
Tagged: #jqwidgets-grid, grid, javascript grid, jquery grid
This topic contains 5 replies, has 2 voices, and was last updated by Joe Weinpert 8 years, 2 months ago.
-
Author
-
I am using the cell rendering feature to place text into a cell. The grid’s height and its row height are set to automatic handling different amounts of data provided to the grid in a different column. How can I vertically center the text in cells in the grid with varying row heights?
Hello Joe Weinpert,
Please, try with
vertical-align: middle;
CSS.Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.comCreating a class like:
.verticalAlign{ vertical-align: middle; }
and then using the cell attribute:
cellclassname: "verticalAlign"
does not work. The text is still rendered at the top of the cell rather than the middle. As mentioned before, I am using the cell attribute:
cellsrenderer: textRenderer
This does work except for a major problem;
cellTextRenderer = function( row, dataField, value, defaultHTML, columnProperties, rowData ){ return "<table style='width: 100%; height: 100%;'><tr><td style='padding: 0px 4px; vertical-align: middle;'>" + rowData.ActionDescribe + "</td></tr></table>" }
The problem happens when, after the cell is rendered, and I click on a
columntype: checkbox
cell in the grid, all the row heights in the whole grid keep getting bigger on each click. This problem is being caused by theheight: 100%;
Any ideas?
Hello Joe Weinpert,
Unfortunately, we do not have such demo.
I prepare one example, please, take a look at this workaround.Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.comThanks for the workaround example! I see the requirements are to use a margin attribute rather then a height attribute within any
cellsrenderer
function. The height attribute was basing itself on the overall grid height and not the current row division height … which is why the each row in the grid would expand on any click until the 100% value was achieved.A
cellbeginedit
function has the ability to get the height of the current row we are doing something in because each row has its own ID generated by jQWidgets. (row0GridName, row1GridName, row2GridName, … ).$( "#row0GridName" ).height()
works fine within anycellbeginedit
function, however, it does not work from within acellsrenderer
function. My guess is because all the cells in the row are being rendered and the height would not be fixed until rendering is done. -
AuthorPosts
You must be logged in to reply to this topic.