Précédent   Forum des professionnels en informatique > Webmasters - Développement Web > JavaScript > Bibliothèques & Frameworks > jQuery
jQuery Forum d'entraide sur le framework jQuery. Avant de poster : Tutoriels jQuery, FAQ jQuery, Tous les tutoriels JavaScript, Toutes les FAQ JavaScript
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 31/08/2011, 17h49   #1
Futur Membre du Club
 
Inscription : septembre 2008
Messages : 103
Détails du profil
Informations forums :
Inscription : septembre 2008
Messages : 103
Points : 18
Points : 18
Par défaut Model Json pour JQGRID

Bonjour, je tente d'utiliser un modèle de json suivant avec le modèle fournit :
JSON dot notation
Code :
1
2
3
4
5
6
7
8
9
10
11
{
   "page":"1",
   "total":2,
   "records":"13", 
   "rows":[ 
      {"id":"12345","name":"Desktop Computers","email":"josh@josh.com","item":{"price":"1000.72", "weight": "1.22" }, "note": "note", "stock": "0","ship": "1"}, 
      {"id":"23456","name":"<var>laptop</var>","note":"Long text ","stock":"yes","item":{"price":"56.72", "weight":"1.22"},"ship": "2"},
      {"id":"34567","name":"LCD Monitor","note":"note3","stock":"true","item":{"price":"99999.72", "weight":"1.22"},"ship":"3"},
      {"id":"45678","name":"Speakers","note":"note","stock":"false","ship":"4"} 
    ] 
}
js code:
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
jQuery("#bigset").jqGrid({	
				//url:'./php/db_json_usr.php',
				url:'./test.json',
				datatype: "json",
				height: 255,
				repeatitems: false,
				//colNames:['id','name', 'login', 'departement', 'file'],
				 colModel:[
						   {name:'name',label:'Name', width:150,editable: true},
						   {name:'id',width:50, sorttype:"int", editable: true},
						   {name:'email',label:'Email', width:150,editable: true,formatter:'email'},
						   {name:'stock',label:'Stock', width:60, align:"center", editable: true,formatter:'checkbox',edittype:"checkbox"},
						   {name:'item.price',label:'Price', width:100, align:"right", editable: true,formatter:'currency'},
						   {name:'item.weight',label:'Weight',width:60, align:"right", editable: true,formatter:'number'},
						   {name:'ship',label:'Ship Via',width:90, editable: true},      
						   {name:'note',label:'Notes', width:100, sortable:false,editable: true,edittype:"textarea", editoptions:{rows:"2",cols:"20"}}      
						 ],
				rowNum:30,
			//   	rowList:[10,20,30],
				mtype: "POST",
				pager: jQuery('#pagerb'),
				pgbuttons: false,
				pgtext: false,
				pginput:false,
				sortname: 'id',
				viewrecords: true,
				sortorder: "asc"
			});
Mais j'ai comme erreur :
Code :
1
2
d is undefined
[Stopper sur une erreur] undefined)c[d[f].toLowerCase()]=parseI...f(typeof e==="string")g=e.split(".");
Si j'utilise un modele type {"page":1,"total":1023,"records":12269,"rows":[{"id":"539","cell":["539","Eddy Lafarque","lae"]} ...
j'arrive à faire fonctionner le code en le modifiant, mais c'est la première syntaxe de json qu'il me faut (sans le cell


Merci pour votre aide
junix est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 01/09/2011, 09h01   #2
Futur Membre du Club
 
Inscription : septembre 2008
Messages : 103
Détails du profil
Informations forums :
Inscription : septembre 2008
Messages : 103
Points : 18
Points : 18
il suffit de rajouter :
Code :
1
2
3
4
jsonReader: {
	repeatitems: false,
	id: "Id" 
},
junix est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 21h48.


 
 
 
 
Partenaires

Hébergement Web