We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Bind columns in the adapter processResponse callback

When I am grabbing data with the data adapter, I am also loading column info. I need a way to bind those columns to the grid once the data has been retrieved. I am doing something like this at the moment,

finalOptions.load = function (args) {
    	    var gridApi = $(element).ejGrid('instance');
 
    	    var adapter = new ej.UrlAdaptor().extend({
    	        processQuery: function (dm, query) {
                    // processing
    	            return {
    	                data: JSON.stringify(req),
    	                url: url,
    	                ejPvtData: p,
    	                type: "POST",
    	                contentType: "application/json; charset=utf-8"
    	            };
    	        },
    	        processResponse: function (data, ds, query, xhr, request, changes) {
                    var columns = formatColumns(data.columns);
    	            gridApi.columns(columns);
    	            return {
    	                count: data.totalItemCount,
                        result: data.data
    	            };
    	        }
    	    });
    	    this.model.dataSource.adaptor = new adapter();
};
However this is throwing an error, in the columns function in the ejGrid source code. On closer inspection it is this line
var $header = this.element.find(".e-gridheader");
this.element[0].replaceChild(this._renderGridHeader()[0], $header[0]);    
Basically there is no $header, it doesn't exist. It doesn't look like it was rendered initially probably because I initialized the grid with no columns and data?

1 Reply

PK Prasanna Kumar Viswanathan Syncfusion Team August 26, 2015 02:22 PM UTC

Hi Umair,

We have reviewed your requirement. Could you  confirm the following details so we can assist you better:

1.       When we render the grid  without datasource and columns in updated script file we will see the below notification. You have mentioned you are using grid without datasource and columns so can you please share your version of script file (ej.web.all.min.js)


2.       Please share your initialization of Grid code snippet or a sample if possible.

Regards,

Prasanna Kumar N.S.V


Loader.
Live Chat Icon For mobile
Up arrow icon