PDA

View Full Version : Array Grid Bug(data in grid column gets truncated)


rahulmca1@gmail.com
04-27-2007, 03:27 AM
Hi,

Found a bug in array grid

Explaination:--
Using
YUI-Ext array grid example:--


// some data yanked off the web
var myData = [
['one<two','three<four','five<six','seven<eight','nine<ten']
];
var dataModel = new YAHOO.ext.grid.DefaultDataModel(myData);
// sortTypes provide support for custom sorting comparison functions
// not needed for this table but here for demonstration
var sort = YAHOO.ext.grid.DefaultColumnModel.sortTypes;

// the DefaultColumnModel expects this blob to define columns. It can be extended to provide
// custom or reusable ColumnModels
var colModel = new YAHOO.ext.grid.DefaultColumnModel([
{header: "Company", width: 200, sortable: true, sortType: sort.asUCString},
{header: "Price", width: 75, sortable: true},
{header: "Change", width: 75, sortable: true},
{header: "% Change", width: 75, sortable: true},
{header: "Last Updated", width: 85, sortable: true}
]);

// create the Grid
var grid = new YAHOO.ext.grid.Grid('example-grid', dataModel, colModel);
grid.render();

grid.getSelectionModel().selectFirstRow();


I used data model
var myData = [
['one<two','three<four','five<six','seven<eight','nine<ten']
];

But in the grid it displayed truncated names as following grid row:--

one three five seven nine

thus truncating <two from is column and similar result in other columns.


thanks.
with regards

rahulmca1@gmail.com
04-27-2007, 07:48 AM
Hi,

Found a bug in array grid

Explaination:--
Using
YUI-Ext array grid example:--


// some data yanked off the web
var myData = [
['one<two','three<four','five<six','seven<eight','n ine<ten']
];
var dataModel = new YAHOO.ext.grid.DefaultDataModel(myData);
// sortTypes provide support for custom sorting comparison functions
// not needed for this table but here for demonstration
var sort = YAHOO.ext.grid.DefaultColumnModel.sortTypes;

// the DefaultColumnModel expects this blob to define columns. It can be extended to provide
// custom or reusable ColumnModels
var colModel = new YAHOO.ext.grid.DefaultColumnModel([
{header: "Company", width: 200, sortable: true, sortType: sort.asUCString},
{header: "Price", width: 75, sortable: true},
{header: "Change", width: 75, sortable: true},
{header: "% Change", width: 75, sortable: true},
{header: "Last Updated", width: 85, sortable: true}
]);

// create the Grid
var grid = new YAHOO.ext.grid.Grid('example-grid', dataModel, colModel);
grid.render();

grid.getSelectionModel().selectFirstRow();


I used data model
var myData = [
['one<two','three<four','five<six','seven<eight','n ine<ten']
];

But in the grid it displayed truncated names as following grid row:--

one three five seven nine

thus truncating <two from is column and similar result in other columns.

Waiting for your response.
thanks.
with regards

Animal
04-27-2007, 08:25 AM
Try using &lt; instead of <

tryanDLS
04-27-2007, 02:14 PM
EDIT: deleted other copy of this thread.

rahulmca1@gmail.com
04-30-2007, 11:20 PM
Hi,

In my case data is populated from database so what should I do Should I look for '<' sign in every column value of the row of array grid and then scan every value for '<' character and replace it accordingly.

For huge data populated from database it would be very costly operation.

Why any characters after '<' symbol are truncated?

When using '>' or '<>' it works fine.


Thanks
With Regards

mystix
05-01-2007, 06:53 AM
this isn't a bug.

since you didn't specifiy custom renderers in your ColumnModel, default renderers are used:Ext.grid.ColumnModel.defaultRenderer = function(value){
if(typeof value == "string" && value.length < 1){
return " ";
}
return value;
};
the default renderer spits out whatever it sees
so "<" marks the beginning of an opening HTML tag
so "<two", "<four" and "<six" become invalid HTML tags which get ignored by the browser


I suggest you inspect your generated page in FireBug. Just specify a custom renderer, or return HTML escaped characters from your database, and your problem is solved.