package com.hp.isomorphic.repro.client;

import java.util.ArrayList;
import java.util.List;

import com.smartgwt.client.data.SortSpecifier;
import com.smartgwt.client.types.SortDirection;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;

public class ListGridSetData extends ListGrid {
	public ListGridSetData() {
		ListGridField field1 = new ListGridField("Col1", "Column 1", 100);
		
		setFields(field1);
		setSort(new SortSpecifier[] { new SortSpecifier("Col1", SortDirection.ASCENDING) });
		refreshFields();

		List<ListGridRecord> recordList = new ArrayList<ListGridRecord>();
		for (int i = 0; i < 10; ++i) {
			ListGridRecord record = new ListGridRecord();
			record.setAttribute("Col1", "Row" + i + " Col1");
			recordList.add(record);
		}

		ListGridRecord[] records = new ListGridRecord[recordList.size()];
		recordList.toArray(records);
		setData(records);
	}
}
