Javascript-форум (https://javascript.ru/forum/)
-   ExtJS (https://javascript.ru/forum/extjs/)
-   -   Не сохраняются настройки grid (https://javascript.ru/forum/extjs/39694-ne-sokhranyayutsya-nastrojjki-grid.html)

Fubu_By 08.07.2013 15:43

Не сохраняются настройки grid
 
хотел сделать чтобы в куках сохранялись изменения отображения колонок, и их сортировка. но чего-то после перезагрузки страницы, сортировка и отображение становиться дефолтным, вот код, подскажите что не доделал, пожалуйста:
Ext.onReady(function(){
	Ext.state.Manager.setProvider(new Ext.state.CookieProvider({
		expires: new Date(new Date().getTime()+(1000*60*60*24*7)), //7 days from now
	}));
var grid = Ext.create('Ext.grid.Panel', {
		id: 'transictionGridID',
		title: 'Комиссии',
		store: storeTransactions,
		disableSelection: false,
		loadMask: true,
		minHeight: 400,
		viewConfig: {
			trackOver: false,
			stripeRows: false
		},
		columns:[{
			id: 'productid',
			text: "ID заявки",
			dataIndex: 'productid',
			flex: 1,
			sortable: true
		},{
			id: 'clientid',
			text: "ID клиента",
			dataIndex: 'clientid',
			flex: 1,
			sortable: true
		},{
			id: 'totalcost',
			text: "Общая",
			dataIndex: 'totalcost',
			flex: 1,
			sortable: true
		},{
			id: 'commission',
			text: "Комиссия",
			dataIndex: 'commission',
			flex: 1,
			sortable: true
		},{
			id: 'orderSubject',
			text: "Предмет",
			dataIndex: 'orderSubject',
			flex: 1,
			sortable: true
		},{
			id: 'workType',
			text: "Вид работы",
			dataIndex: 'workType',
			flex: 1,
			sortable: true
		},{
			id: 'rebill',
			text: "Повтор",
			dataIndex: 'rebill',
			flex: 1,
			sortable: true
		},{
			id: 'city',
			text: "Город",
			dataIndex: 'city',
			flex: 1,
			sortable: true
		},{
			id: 'orderStatus',
			text: "Статус заявки",
			dataIndex: 'orderStatus',
			flex: 1,
			sortable: true
		},{
			id: 'planFinishTime',
			text: "Запланирован",
			dataIndex: 'planFinishTime',
			flex: 1,
			sortable: true
		},{
			id: 'DateOrder',
			text: "В разработку",
			dataIndex: 'DateOrder',
			flex: 1,
			sortable: true
		},{
			id: 'DateClosed',
			text: "Закрыт",
			dataIndex: 'DateClosed',
			flex: 1,
			sortable: true
		},{
			id: 'DateReceived',
			text: "Создан",
			dataIndex: 'DateReceived',
			flex: 1,
			sortable: true
		},{
			id: 'campaign',
			text: "Компания",
			dataIndex: 'campaign',
			flex: 1,
			sortable: true
		},{
			id: 'channel',
			text: "Субаккаунт",
			dataIndex: 'channel',
			flex: 1,
			sortable: true
		},{
			id: 'Data1',
			text: "Data1",
			dataIndex: 'Data1',
			flex: 1,
			sortable: true
		},{
			id: 'Data2',
			text: "Data2",
			dataIndex: 'Data2',
			flex: 1,
			sortable: true
		},{
			id: 'payoutstatus',
			text: "Статус оплаты",
			dataIndex: 'payoutstatus',
			flex: 1,
			sortable: true
		}],
		bbar: Ext.create('Ext.PagingToolbar', {
			store: storeTransactions,
			displayInfo: true,
			displayMsg: 'Записи {0} - {1} of {2}',
			emptyMsg: "Нет записей",
			items:['-', {
				xtype: 'button',
				text: 'Экспортировать в csv-файл',
				handler: function(){
					window.location.href = '/pap-test/?action=download&content=transactions&orderby=dateinserted&orderpre=DESC&';
				}
			}]
		}),
		renderTo: 'grid-transactions-stats', 
		stateful: true,
		stateId:'transictionGridStateID'
	});

FireVolkhov 09.07.2013 21:49

Если тестишь на локальной машине, открывая html док в браузере,
то тогда тебе сюда https://ru.wikipedia.org/wiki/HTTP_cookie
Если нет, то попробуй
Ext.state.Manager.setProvider(new Ext.state.LocalStorageProvider());


Часовой пояс GMT +3, время: 02:42.