Issue loading REST json

Hi

I use an existing REST server, so i don’t have the hand to the REST json result.

my json file is like this :
{“items”:
[
{“request_id”:60614078,“user_concurrent_program_name”:“A”,“concurrent_program_name”:“XX_ETAT_AVOIRS”,“printer”:“IMPTXT”,“user_name”:“GRC”,“actual_completion_date”:“2021-09-23T06:22:19Z”,“nom_cible”:“B”,“rep_cible”:“Autres Etats comptables de recette”,“ext_cible”:“csv”,“annee”:“2021”,“mois”:“09-Septembre”,“outfile_name”:“D1”,“portal_name”:“D3”},
{“request_id”:60606077,“user_concurrent_program_name”:“A”,“concurrent_program_name”:“XXJGZZSTB3”,“printer”:“IMPTXT”,“user_name”:“GRC”,“actual_completion_date”:“2021-09-23T03:31:27Z”,“nom_cible”:“C”,“rep_cible”:“Balance rapide stockée”,“ext_cible”:“csv”,“annee”:“2021”,“mois”:“09-Septembre”,“outfile_name”:“D2”,“portal_name”:“D4”}
]
}

I don’t know how to load it

however if i make the following json file :
[
{“request_id”:60614078,“user_concurrent_program_name”:“A”,“concurrent_program_name”:“XX_ETAT_AVOIRS”,“printer”:“IMPTXT”,“user_name”:“GRC”,“actual_completion_date”:“2021-09-23T06:22:19Z”,“nom_cible”:“B”,“rep_cible”:“Autres Etats comptables de recette”,“ext_cible”:“csv”,“annee”:“2021”,“mois”:“09-Septembre”,“outfile_name”:“D1”,“portal_name”:“D3”},
{“request_id”:60606077,“user_concurrent_program_name”:“A”,“concurrent_program_name”:“XXJGZZSTB3”,“printer”:“IMPTXT”,“user_name”:“GRC”,“actual_completion_date”:“2021-09-23T03:31:27Z”,“nom_cible”:“C”,“rep_cible”:“Balance rapide stockée”,“ext_cible”:“csv”,“annee”:“2021”,“mois”:“09-Septembre”,“outfile_name”:“D2”,“portal_name”:“D4”}
]

I have no problem to load it

How to handle the prefix {“items”: … } ? someone has a suggestion ?

probably DataCollection manipulation ?

If needed (portion of code) :

in

in
const dataCollection = new dhx.DataCollection();

const grid2 = new dhx.Grid("grid2", {
	columns: [
		{ 
			id: "request_id", 
			header: [{ text: "N° de Trt PGI", rowspan: 2}],
			footer: [{content: "count"}],
			},
		{ 
			id: "user_concurrent_program_name", 
			header: [{ text: "Nom"}, { content: "selectFilter"}] 
			},
		{ 
			id: "actual_completion_date", 
			header: [{ text: "Imprimé le", rowspan: 2  }],
			template: dateTemplate,
			},
		{ 
			id: "nom_cible", 
			header: [{ text: "Nom cible", rowspan: 2  }] 
			},
		{ 
			id: "rep_cible", 
			header: [{ text: "Catégorie"}, { content: "selectFilter"}] 
			},
		{ 
			id: "ext_cible", 
			header: [{ text: "Extension", rowspan: 2  }] 
			},
		{ 
			id: "annee", 
			header: [{ text: "Année"}, { content: "selectFilter" }] 
			},
		{ 
			id: "mois", 
			header: [{ text: "Mois"}, { content: "selectFilter" } ] 
			},
		{ 
			id: "icon", 
			header: [{ text: "", rowspan: 2  }],
			//template: value =>  "<div style='color:green'>TEST</div>",
			template: iconTemplate,
			htmlEnable: true,
			align: "center"
			}
	],
	adjust: true,
	autoWidth: true,
	selection:"row",
	data : dataCollection
});

dataCollection.load("./portail_v1.json");

I found a solution :

i replace
dataCollection.load(url);

by

dhx.ajax.get(url).then(function (data) {
dataCollection.parse(data.items); //I parse data.items instead of data
});

however, i think i can’t use lazyloading in this case
anyone have suggestion ?

To use Dynamic loading the server side must returns three parameters in the response ( data, from and total_count). See the docs form more info. In your case will be impossible because you have not control over your REST API. How many items you will process?

about 50000 …
probably too much for a grid…(with many local filtering)

thx, i will filter more the data on server side

That’s another detail, when you enable dynamic loading you can’t apply filters unless all the data has been already loaded.