Page 1 of 1

Correct way to display in jqGrid

Posted: Mon Nov 09, 2015 10:59 am
by publicGenome
Hi There,
I'm learning jqgGrid, and looks like I've entered into an infinite loop (lost). My query is:
1) Should I get data first and then work on jquery Java script code or
2) Begin with Jqgrid and then inside it get data.

With 1st method I get a Grid but don't know how to populate the values from the json data received.
Code for 1:

Code: Select all


	$.get('test/xhr_get_data',function(data,status){
		//test - controller, xhr_get_data - method 
		console.log(data); //to check if data has reached..

		for(var i=0;i<data.length;i++){
			console.log(data[i].study+" "+data[i].forward_primer +" "+data[i].sample_name);			//to check
		}
//begin jqgrid now.. Cannot get the data inside jqgrid
		$("#grid_illume").jqGrid({
			datatype: "json",
			width: 1000,
			colNames:['study'],
			
	           colModel :[ 
	                      {name:'study'}  ],

			pager: '#pager_illume',
			height: 'auto',
			gridview: true,
			viewrecord:true,
			sortorder:"asc",
			sortable:true,
			caption:"jqGrid Illume Example" //title of the grid
		});
		return false;
	},'json');
For 2: Don't know what's happening, I can see the json data in response using inspect element though. But after that everything is blank.
Code for 2:

Code: Select all


$("#grid_illume").jqGrid({
		//nothing seems to work
		url:'test/xhr_get_data',
		datatype: "json",
			
			complete: function(jsondata, stat) {
		        if (stat == "success") {
		        	alert("hahhahha");
		        	console.log("inside");
		     
		        }
		        else{
		        	alert("zzzzzzzzzz");
		        	console.log("inside_2");
		        }
		    }		
	});
My data looks like:
{"study":"Denmark_nasal","forward_primer":"ACTGH","reverse_primer":"","sample_name":"A101"}
Which is the correct approach?
Kindly guide on how to display data on jqGrid properly.
Thanks.!!

Re: Correct way to display in jqGrid

Posted: Mon Nov 09, 2015 4:56 pm
by publicGenome
*Gentle* Bump to the post.