jQuery UI Widgets › Forums › Grid › Autoheight broken by adding a cellrenderer function
Tagged: autoheight, autorowheight, cellsrenderer, grid, jqxgrid
This topic contains 2 replies, has 2 voices, and was last updated by swisspen 10 years, 6 months ago.
-
Author
-
Hello,
I have the latest version of JQWidgets – 3.2.2. My grid has autorowheight and autoheight both set to “true”, and this works perfectly with the JSON-formatted data I pull from my database. However, the database data includes Language_id and Location_id, which are numerical values like 1, 2 and 3. To display the text value corresponding to these values, I have a JS script, and when I apply it (see below), the text values are displayed perfectly … BUT the autorowheight doesn’t work any more!
The code is: `
$(document).ready(function ()
{
var paramString = “&nameFirst=” + “<?php echo $_SESSION[‘first’]?>” + “&nameLast=” + “<?php echo $_SESSION[‘last’]?>”;
var data1 =
{
datatype: “json”,
datafields: [
{ name: ‘id’},
{ name: ‘name_first’},
{ name: ‘name_last’},
{ name: ‘organization’},
{ name: ’email’},
{ name: ‘phone’},
{ name: ‘comments’},
{ name: ‘language_id’},
{ name: ‘location_id’}
],
url: ‘stcg-json-responses.php?fct=getJSONAllMembers’ + paramString,
sortcolumn: ‘id’,
sortdirection: ‘desc’,
async: false
};//end data source//ASSIGN ADAPTER 1 TO SOURCE DATA
var adapter1 = new $.jqx.dataAdapter(data1);var columns = [
{ text: ‘Id’, datafield: ‘id’, width: 50 },
{ text: ‘First Name’, datafield: ‘name_first’, width: 90 },
{ text: ‘Last Name’, datafield: ‘name_last’, width: 110 },
{ text: ‘Organization’, datafield: ‘organization’, width: 120 },
{ text: ‘Email’, datafield: ’email’, width: 200 },
{ text: ‘Phone’, datafield: ‘phone’, width: 120 },
{ text: ‘Comments’, datafield: ‘comments’, width: 300 },
/* { text: ‘Language’, datafield: ‘language_id’, width: 160},
{ text: ‘Location’, datafield: ‘location_id’, width: 160}*/
{ text: ‘Language’, datafield: ‘language_id’, width: 160, cellsrenderer: function(row, columnfield, value, defaulthtml, columnproperties, rowdata)
{
return langNumToText(value);
}
},
{ text: ‘Location’, datafield: ‘location_id’, width: 160, cellsrenderer: function(row, columnfield, value, defaulthtml, columnproperties, rowdata)
{
return locationNumToText(value);
}
}
];//INITIALIZE GRID 1
$(“#jqxgrid1”).jqxGrid(
{
width: 1300,
height: 800,
source: adapter1,
sortable: true,
theme: ‘classic’,
selectionmode: ‘singlerow’,
autorowheight: true,
autoheight: true,
editable: false,
columns: columns
});//end grid
});
</script>
`As you can see, I currently have the text WITHOUT the cellsrendering commented out, so my autoheight is not working. As soon as I comment out the Language and Location statements WITH the cellsrendering, autoheight works again fine.
Is there another way to use my script that WON’T break autoheight?
Hello swisspen,
Please check the following forum post for more information on such situations: http://www.jqwidgets.com/community/topic/grid-rowsize-using-custom-cellsrenderer/#post-50710.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Hi Dimitar,
Many thanks – that is most helpful. (Latency problem … tricky.)
Best,
SP -
AuthorPosts
You must be logged in to reply to this topic.