Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 813
Registered: ‎05-29-2012
My Device: see later
My Carrier: see later

Creating a listview

[ Edited ]
[
	{ 	
        "firstName" : "Mike",
		"lastName" : "Chepesky",
		"employeeNumber" : 01840192
	},
	{
		"firstName" : "Westlee",
		"lastName" : "Barichak",
		"employeeNumber" : 47901927
	},
	{ 	
        "firstName" : "Jamie",
		"lastName" : "Lambier",
		"employeeNumber" : 51239657
	},
	{ 	
        "firstName" : "Denise",
		"lastName" : "Marshall",
		"employeeNumber" : 41239520
	},
	{ 	
        "firstName" : "Matthew",
		"lastName" : "Taylor",
		"employeeNumber" : 01963597
	},
	{ 	
        "firstName" : "Mark",
		"lastName" : "Tiegs",
		"employeeNumber" : 65321951
	},
	{ 	
        "firstName" : "Karla",
		"lastName" : "Tetzel",
		"employeeNumber" : 03266987
	},
	{ 	
        "firstName" : "Ian",
		"lastName" : "Dundas",
		"employeeNumber" : 29472012
	},
	{ 	
        "firstName" : "Marco",
		"lastName" : "Cacciacarro",
		"employeeNumber" : 56446691
	}
]

 

 

thats my json file

 

i do this

 

	ListView *listView = root->findChild<ListView*>("listIt");
		GroupDataModel *model = new GroupDataModel(
				QStringList() << "firstName" << "lastName");

		// Create a JsonDataAccess object and load the .json file. The
		// QDir::currentPath() function returns the current working
		// directory for the app.
		JsonDataAccess jda;
		QVariant list = jda.load(QDir::currentPath() +
		    	                         "/app/native/assets/employees.json");
		model->insertList(list.value<QVariantList>());

		// Set the data model for the list view
		listView->setDataModel(model);

 

 

why does it get sorted , and employee number shows up in each line?

 

How can I create the table from that json file..with first name/last name besides each other

 

Plus, how can I on click of item component pull a move?

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Creating a listview

GroupDataModel is a sorted data model...

 

http://developer.blackberry.com/native/reference/cascades/bb__cascades__groupdatamodel.html


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Creating a listview

There's some examples here on how to work with JSON...

 

http://developer.blackberry.com/native/reference/cascades/bb__data__jsondataaccess.html


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.