Rajout du bouton Filter dans la barre de menu¶
Pour Rajouter le bouton Filter, il faut dans le fichier Livegrid.js (client-user/js/components/dataviews/livegrid) :
- Rajouter le code suivant dans l'élément this.topBar (l.507) :
{ text : i18n.get("label.filter"), scope : this, handler : function () { var pos = this.getPosition(); var up = new sitools.widget.filterTool({ pos : pos, store : this.storefilters, columnModel : config.datasetCm, }); up.show(); }, icon : loadUrl.get('APP_URL') + "/common/res/images/icons/hmenu-asc-all.png" }
- Rajouter dans la fonction sitools.user.component.dataviews.livegrid.LiveGrid (l.248), après la ligne
:var xg = Ext.grid
this.storefilters = new sitools.user.component.dataviews.tplView.StoreTplView({ datasetCm : config.datasetCm, urlRecords : this.urlRecords, sitoolsAttachementForUsers : this.sitoolsAttachementForUsers, userPreference : config.userPreference, bufferSize : DEFAULT_LIVEGRID_BUFFER_SIZE, formParams : config.formParams, formMultiDsParams : config.formMultiDsParams, mainView : this, datasetId : config.datasetId, filtersCfg : config.filtersCfg, isFirstCountDone : false }); this.storefilters.filters = new sitools.widget.FiltersCollection({ filters : config.filters }); this.storefilters.on("beforeload", function (storefilters, options) { //set the nocount param to false. //before load is called only when a new action (sort, filter) is applied var noCount; if (!storefilters.isFirstCountDone || storefilters.isNewFilter) { options.params.nocount = false; } else { options.params.nocount = true; } if (storefilters.isNewFilter) { options.params.start = 0; options.params.limit = DEFAULT_LIVEGRID_BUFFER_SIZE; } storefilters.isNewFilter = false; if (!Ext.isEmpty(storefilters.filters)) { var params = storefilters.buildQuery(storefilters.filters.getFilterData()); Ext.apply(options.params, params); } if (!Ext.isEmpty(this.dataView)) { this._loadMaskAnchor = Ext.get(this.el.dom); this._loadMaskAnchor.mask(i18n.get('label.waitMessage'), "x-mask-loading"); } this.storefilters.storeOptions(options); //this.el.mask(i18n.get('label.waitMessage'), "x-mask-loading"); }, this); this.storefilters.on('load', function (store, records, options) { if (this._loadMaskAnchor && this._loadMaskAnchor.isMasked()) { this._loadMaskAnchor.unmask(); } var plotComp = Ext.getCmp("plot" + config.datasetId); if (plotComp) { var rightPanel = plotComp.findById('plot-right-panel'); var success = rightPanel.fireEvent('buffer', storefilters); } this.storefilters.isFirstCountDone = true; }, this); this.storefilters.load({ params : { start : 0, limit : DEFAULT_LIVEGRID_BUFFER_SIZE } });
- Enfin enlever (ou mettre en commentaire), le morceau de code suivant :
/* * the filters of the grid */ /* var filters = sitools.user.component.dataviews.dataviewUtils.getFilters(config.datasetCm, config.filters); // Using the extended gridFilter to filter with the columnAlias var filtersSimple = new Ext.ux.grid.GridFiltersSpe({ encode : false, // json encode the filter query local : false, // defaults to false (remote filtering) filters : filters }); var myStoreSimple = new sitools.user.component.dataviews.livegrid.StoreLiveGrid({ datasetCm : config.datasetCm, urlRecords : this.urlRecords, sitoolsAttachementForUsers : this.sitoolsAttachementForUsers, userPreference : config.userPreference, bufferSize : DEFAULT_LIVEGRID_BUFFER_SIZE, formParams : config.formParams, formMultiDsParams : config.formMultiDsParams, mainView : this, datasetId : config.datasetId }); myStoreSimple.addListener("beforeload", function (store, options) { //set the nocount param to false. //before load is called only when a new action (sort, filter) is applied if (!store.isInSort || store.isNewFilter) { options.params.nocount = false; } else { options.params.nocount = true; } store.isInSort = false; store.isNewFilter = false; this._loadMaskAnchor = Ext.get(this.getView().mainBody.dom.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode); this._loadMaskAnchor.mask(i18n.get('label.waitMessage'), "x-mask-loading"); //this.el.mask(i18n.get('label.waitMessage'), "x-mask-loading"); }, this); myStoreSimple.addListener("load", function (store, records, options) { if (this._loadMaskAnchor && this._loadMaskAnchor.isMasked()) { this._loadMaskAnchor.unmask(); } }, this);