jQWidgets Forums

jQuery UI Widgets Forums Grid Display column headers dynamically

This topic contains 1 reply, has 2 voices, and was last updated by  Peter Stoev 10 years, 7 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Display column headers dynamically #63853

    sri1241
    Participant

    How to display the column headers and column names dynamically in grid using array.

    var commonList = [];
    	var columns = [];
    	var firstList = [{ "text": "Id ", "datafield": "id"}, 
    	                    { "text": "Name", "datafield": "name"}];
    	
    	var secondList = [{ "text": "Second Id ", "datafield": "id"}, 
    	                    { "text": "Second Name", "datafield": "name"}];
    	SampleService.setParameter = function(pageFrom){
    		columns = new Array();
    		if(pageFrom=="First") {
    			commonList = firstList ;
    		}else if (pageFrom=="Second"){
    			commonList = SecondList;
    		}
    	     for (var i = 0; i < commonList.length; i++) {
    	         columns.push({ text: commonList[i].text, datafield: commonList[i].datafield });
    	     }
    	  }
    SampleService.SampleSource = {
    		datatype: "json",
    		datafields: [
    		        {name:'id'},
    			{name:'name'}
    		]
    	};
    	SampleService.SampleAdapter = new $.jqx.dataAdapter(SampleService.SampleSource);
    
    	SampleService.SampleGrid = {
    		width : '99.8%',
    		autoheight: true,
    		showheader : true,
    		columnsheight : 30,
    		columnsreorder : true,
    		source : SampleService.SampleAdapter,
    		columns : columns
    	};

    Please help.

    Display column headers dynamically #63866

    Peter Stoev
    Keymaster

    Hi sri1241,

    These should be set during the Grid’s initialization. Then you can change properties and set them to other values.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.