-
12 Feb 2013 10:44 AM #1
Unanswered: Null value in model causing a blank row in grid
Unanswered: Null value in model causing a blank row in grid
Basically, I have a model like:
Well I figured out that those values can and will likely be null at some point. So the mapping kinda does its job. The return value for them is a blank string.Code:{name: 'cnoID', type: 'string', mapping: function(o) { var root = o.cnoTypeList[0] || false, val = root.id || false; if (root && val) return val; }, {name: 'cnoType', type: 'string', mapping: function(o) { var root = o.cnoTypeList[0] || false, val = root.id || false; if (root && val) return val; }
Well, I am using this information in a grid. The columns dataIndexes are set to the names of the model values and it works out... Unless the values are empty strings.... Then it just inserts a blank row into the grid....
I figured that the blank string was causing the blank row, so I used defaultValue: null to counteract it. It didn't work... It makes the value null, but it still inserts the blank row
Anyone have this issue before or see what I am doing wrong? I am using EXT JS 4.1Last edited by jeffshaver; 12 Feb 2013 at 10:56 AM. Reason: A little peiece i missed
-
12 Feb 2013 11:47 AM #2
Even if a field value for a record is empty, the grid will still show the row. You could add a filter to your store and filter out these blank records so that they don't show on the grid.
http://docs.sencha.com/ext-js/4-1/#!...-method-filter
-
12 Feb 2013 12:00 PM #3
But...
But...
What would be causing a blank row to display? If it isn't supposed to happen, then I am probably doing something wrong, right?
-
12 Feb 2013 12:14 PM #4
Sorry....
Sorry....
I totally read that response wrong... I will try this tomorrow and will respond then. Thanks!
-
13 Feb 2013 4:07 AM #5
I can't get it working. I add:
I just want to get rid of specific values that are blank, not the whole record. It looks like item is the whole record in that caseCode:filters: [{ function(item) { return item == ''; } }]
-
13 Feb 2013 5:50 AM #6
Yes, you are correct, the item will refer to the entire record, but you can reference fields within the record by using the get method. If you wanted to exclude all records where the cnoId is blank you could define it as:
Code:filters: [{ function(item) { return item.get('cnoId') !== ''; } }]
-
14 Feb 2013 5:05 AM #7
What I had to do...
What I had to do...
Basically, I had to scrap mapping/converting altogether.
I brought it into one store, and then inside the datachanged listener on the store, I pass that data to other stores, which the grids are now based on.
It works this way.
The problem was only parts of a record would be empty and I was using one store for multiple grids grabbing only pieces of the record.


Reply With Quote