Dojo/Dijit: Change sorting and what columns to render in ContentQueryGrid

Member since: 2007

Hi,

How can I change what to sort on and which columns to render in my component? Default sorting is name descending and name and status columns are rendered.

I've tried to set the queryOptions from my component, but with no luck. My grid's attach point is contentQuery.

var queryOptions = {};
queryOptions.sort = [{ attribute: "anotherColumn", descending: false }];

this.contentQuery.grid.set("queryOptions", queryOptions);

One way that seems to work is to inherit from the grid and create my own, but that seems unnecessary?

#89432 Aug 15, 2014 22:36
  • Member since: 2008

    I have the same need. Anyone?

    #90854 Sep 19, 2014 9:38
  • Member since: 2007

    Sorry Alexander, missed your question here. Yes, ther is a fix for this. I ended up overriding the fetchData method in postCreate. I have not changed which columns to render though.

    postCreate: function () {
    	this.contentQuery.fetchData = this.fetchData;
    	this._reloadQuery();
    },
    
    fetchData: function () {
    	this.grid.set("queryOptions", {
    		ignore: ["query"],
    		sort: [{
    			attribute: "name",
    			descending: false
    		}]
    	});
    
    	var queryParameters = this.queryParameters || {};
    	queryParameters.query = this.queryName;
    
    	this.grid.set("query", queryParameters);
    },
    
    _queryTextChanged: function (value) {
    	this._reloadQuery();
    },
    
    _reloadQuery: function () {
    	this.contentQuery.set("queryParameters", { q: this.queryText.value });
    	this.contentQuery.set("queryName", this.queryName);
    }

    Hope this helps.

    #91244 Sep 30, 2014 19:05