PDA

View Full Version : Grid Columns property allowBlank: false question



bryanevil
11 Jul 2010, 6:24 PM
Hi All

I have the below columns setup in my grid. I thought the allowBlank: false property will help validate my companyname is not empty in client side, before extjs will actually send the "create" post back to my web service, but it was not the case. Am I doing things wrong ? or allowBlank is not for such use?


var CompanyColumn = [
{ header: 'ID', width: 200, sortable: true, dataIndex: 'ID', allowBlank: true },
{ id: 'CompanyName', header: 'Company Name', width: 400, sortable: true, dataIndex: 'CompanyName', editor: new Ext.form.TextField(), allowBlank: false }

];


tuv.grid.companyGrid = Ext.extend(tuv.grid, {
store: CompanyInfoJsonStore,
columns: CompanyColumn,
autoExpandColumn: 'CompanyName',
title: 'Company List',
stateId: 'CompanyGridState',

bbar: new Ext.PagingToolbar({
pageSize: tuv.grid.companyGrid.pagesize,
store: CompanyInfoJsonStore,
displayInfo: true,
displayMsg: 'Displaying topics {0} - {1} of {2}',
emptyMsg: "No topics to display"
})
});

Condor
11 Jul 2010, 9:53 PM
A column doesn't have an allowBlank config option.

1. A TextField (which you are using as editor) has an allowBlank config option.
2. A Record field also has an allowBlank config option that is part of the validation if the record can be autoSaved.

bryanevil
11 Jul 2010, 10:10 PM
2. A Record field also has an allowBlank config option that is part of the validation if the record can be autoSaved.

What if I don't allow autoSave?

Condor
11 Jul 2010, 10:15 PM
If you configure a field with allowBlank:false and you enter a blank value for the field, the record won't be saved to the server and will remain dirty.

bryanevil
14 Jul 2010, 7:55 PM
If you configure a field with allowBlank:false and you enter a blank value for the field, the record won't be saved to the server and will remain dirty.

I make validation work by setup my reader , but I want the field with no value and allowblank is false to have a red corner. How to setup for that? Currently red corner does not appear at any case.

P.S. auto save is false

var companyinfoReader = new Ext.data.JsonReader({
totalProperty: 'TotalCount',
successProperty: 'success',
root: 'Data',
idProperty: 'ID',
messageProperty: 'ResponseMessage',
fields: [
{name: 'CompanyName', allowBlank:false},
{name: 'ID'/*, mapping: 'ID'*/ }
]
});

Condor
14 Jul 2010, 11:08 PM
The red triangle is for dirty fields. You want the red squigly line.

You'll have to setup a renderer for the column that sets meta.attr to a css class that will show the red line if the field is invalid.