开发者

Grouping an Ext JS 4.0.2a Grid on a Column that Contains a null value

开发者 https://www.devze.com 2023-04-03 08:35 出处:网络
I have a model called \'Students\' where one of the fields \'Team\' is defined as: { name: \'team\', type: \'int\',

I have a model called 'Students' where one of the fields 'Team' is defined as:

{
  name: 'team',
  type: 'int',
  useNull: true
}

Now I want to group on this field using:

Ext.getStore('Students').group('team');

And it's throwing this error "Unc开发者_如何学编程aught TypeError: Cannot call method 'get' of null".

I tested if the absence of nulls fixes the issue by filling the nulls in with empty strings and the error went away.

How can I fix this so I'm able to group nulls into their own group? Without throwing the error?


You can set convert setting to team field in model.

{
  name: 'team',
  type: 'int',
  useNull: true,
  convert: function(value) {
    return: value ? value : 0;
  }
}

then you can use int zero instead of null.

0

精彩评论

暂无评论...
验证码 换一张
取 消