I want to set a whole record from a store to dirty. I have already tried record.setDirty() but this method is deprecated.
ExtJS Record#Set
The second argument to set accepts an "options" object, where you can specify dirty: true | false
record.set({ name: 'value', age: 42}, {
dirty: true
});
record.set({}, {
dirty: true
});
Related
i have a form that is being loaded with the use of schema-form, in that form i have a field MaxCardshis value is the value from db, and it can be null in the server-side i transformed null to -1
MaxCards = domainColumn.MaxCards.HasValue ? domainColumn.MaxCards.Value : -1
When the value -1 is loaded i dont want to show it in the form UI, instead i want to show an empty string.
How can I achieve it?
this is how i load the form: (Key: MaxCards is the field that i am talking about)
vm.form = [{
key: 'Name',
readonly: false
}, {
key: 'MaxCards',
readonly: false,
fieldHtmlClass: "editColumnModel-maxCards"
}, {
key: 'Description',
readonly: false,
type: 'textarea'
}];
You can try, replacing your -1 values, though I would suggest you to return blank space from your service/controller instead of -1 (null) if the type safety is not a concern.
{{ domainColumn.MaxCards.Value.replace('-1', ' ') }}
Or
$scope.domainColumn.MaxCards.Value.replace('-1', ' ');
I have not tested this nor I am sure what values your code returns, so please feel free to tweak this code a little.
I just tried to use this code:
field: 'field1',
filter: {
term: 1,
condition: uiGridConstants.filter.STARTS_WITH,
placeholder: 'starts with...',
ariaLabel: 'Starts with filter for field1',
flags: { caseSensitive: false },
type: uiGridConstants.filter.SELECT,
//selectOptions: [{ value: '1', label: 'male' }, { value: '2', label: 'female' }],
selectOptions: [$scope.DropdownEntries],
disableCancelFilterButton: false
}
The gridOptions selectOption array which come back form DropdownEntries is empty because the variables in DropdownEntries() are not accessible if gridOptions are not set, they come from a Webservice and it takes longer to load them as gridOptions are set.
Is there any possibility to "reload" the gridOptions after I`m sure that all variables are accessible ? Or is there another way to solve this problem
I am new in AngularJS and Ui-Grid thanks for helping me !
You can initialize the selectOptions with an empty array and reassign them when the data becomes available
See this question.
Then you should wait for that promise to be resolved and after that set selectOptions, something like this:
$http.get(url).then(function(response) {
gridOptions.filter.selectOptions = response.data.dropdownEntries;
})
Another possibility is to resolve that promise before entering the controller that sets ui-grid options.
https://docs.angularjs.org/api/ngRoute/service/$route#example
My filter looks like this:
{
type: 'boolean',
dataIndex: 'FutureProfile',
value:false,
defaultValue : false
},
This does not add any sort of default filtering for my data. This brings back every row in the table.
If I do this:
{
type: 'boolean',
dataIndex: 'FutureProfile',
value:true,
defaultValue : false
},
Everything works fine and when the grid is loaded, the FutureProfile rows only display for items that have the boolean value of true.
So it seems if the value is set to false, extjs completely ignores this and does not send this as part of the ajax call, if it's set to true, the filter is sent via ajax. How would I make the grid actually default to rows with a false value for FutureProfile?
Figured it out after much trial and error.
If you want the default value of a boolean filter to work, you must set active to true:
{
type: 'boolean',
dataIndex: 'FutureProfile',
value:false,
active: true
}
Whenever a store (Ext.data.Store) reads data from the server, it sends paging parameters like &page=1&start=0&limit=25 in a json proxy or [page:1, start:0, limit:25] using a direct proxy.
I'd like to disable paging in the store or proxy configuration.
I found this workaround, but I'm sure there must be a better method.
proxy: {
pageParam: undefined,
startParam: undefined,
limitParam: undefined,
...
}
Does anyone know how to disable paging properly ?
Another option is to override the proxy's getParams method. This handles the groupers, sorters, filters, page, start and limit parameters.
It's defined in Ext.data.proxy.Server
If you want to disable all Extjs used parameters, then you can simple replace it with an empty method:
proxy: {
getParams: Ext.emptyFn,
...
}
You can also extend the proxy class and override this method.
store: {
pageSize: 0,
limit:0,
....
}
excluding from the request
page: __
start: __
limit: ___
I set:
pageSize: 0,
in the model config.
To disable pagination, you have to set the values to empty string, not undefined. Like so:
pageParam: '',
startParam: '',
limitParam: '',
This works for me in Ext JS 6.2
set the following on the store:
{
defaultPageSize: null
}
I have a working sort-able grid using the ext 3.4 grid filter plugin. I would like to default the active column to filter true values. User who needs the inactive records could remove the filter. How do I specify a default filter column and value?
Thanks in advance!
colModel: new Ext.grid.ColumnModel({
defaults: {
sortable: true
// How do I specify a default filter value
//
// Only show active records unless the user changes the filter...
},
columns: [{
dataIndex:'f_uid',
id:'f_uid',
header:'ID',
hidden:true
}, {
dataIndex:'f_name',
id:'f_name',
header:'Name',
}, {
xtype:'booleancolumn',
dataIndex:'f_active',
id:'f_active',
header:'Active',
filterable:true,
trueText:'Active',
falseText:'Inactive'
}]
I realise this is an old question but it took me a while to find a solution, therefore I thought I would share.
1) The filter can be set using the value property in the filter.
filter: {
type: 'LIST',
value: ['VALUE TO FILTER']
}
2) In order to initially filter the data use the filterBy() method in the store. This could be defined in the onRender event handler.
this.getStore().load({
scope:this,
callback: function() {
// filter the store
this.getStore().filterBy(function(record, id) {
// true will display the record, false will not
return record.data.DATA_TO_FILTER == 'VALUE TO FILTER ';
});
}
});
The answer was in the Filter.js source code. The filter object within the column definition can be used to configure the default behavior.
}, {
xtype:'booleancolumn',
dataIndex:'f_active',
id:'f_active',
header:'Active',
trueText:'Active',
falseText:'Inactive',
filterable:true,
filter: {
value:1, // 0 is false, 1 is true
active:true // turn on the filter
}
}
I have encountered the same problem and I found that #John's answer is right, I can make it work with the sample http://dev.sencha.com/deploy/ext-4.0.0/examples/grid-filtering/grid-filter-local.html, for the grid-filter-local.js, just add the code like:
grid.getStore().load({
scope:this,
callback: function() {
// filter the store
grid.getStore().filterBy(function(record, id) {
// true will display the record, false will not
return record.data.size === 'small';
});
}
});
before the original code store.load(), and wipe off the store.load().
Then it will only show the record with size equals 'small' at the first load of the web page. Cheers!
I've made a universal helper class that allows you to set any default values in column definition.
https://gist.github.com/Eccenux/ea7332159d5c54823ad7
This should work with both remote and static stores. Note that this also works with filterbar plugin.
So your column item is something like:
{
header: 'Filename',
dataIndex: 'fileName',
filter: {
type: 'string',
// filename that starts with current year
value: Ext.Date.format(new Date(), 'Y'),
active:true
}
},
And then in your window component you just add something like:
initComponent: function() {
this.callParent();
// apply default filters from grid to store
var grid = this.down('grid');
var defaultFilters = Ext.create('Ext.ux.grid.DefaultFilters');
defaultFilters.apply(grid);
},