protected override NWidget CreateExampleContent() { /* // create a memory data table that supports null values * NMemoryDataTable table = new NMemoryDataTable(); * table.AddField(new NFieldInfo("Name", typeof(string), true)); * table.AddField(new NFieldInfo("Birthday", typeof(DateTime), true)); * table.AddField(new NFieldInfo("Country", typeof(ENCountry), true)); * table.AddField(new NFieldInfo("Email", typeof(string), true)); * * Random rnd = new Random(); * for (int i = 0; i < NDummyDataSource.PersonInfos.Length; i++) * { * NDummyDataSource.NPersonInfo personInfo = NDummyDataSource.PersonInfos[i]; * * bool nullName = (rnd.Next(8) == 1); * bool nullBirthday = (rnd.Next(8) == 2); * bool nullCountry = (rnd.Next(8) == 3); * bool nullEmail = (rnd.Next(8) == 4); * * table.AddRow( * (nullName? null: personInfo.Name), // name * (nullBirthday? null: (object)personInfo.Birthday), // birthday * (nullCountry ? null : (object)personInfo.Country), // country * (nullEmail? null: personInfo.Email)); // email * }*/ // create a memory data table that supports null values NMemoryDataTable table = new NMemoryDataTable(); table.AddField(new NFieldInfo("Name", typeof(string), true)); Random rnd = new Random(); for (int i = 0; i < 1; i++) { NDummyDataSource.NPersonInfo personInfo = NDummyDataSource.PersonInfos[i]; bool nullName = (rnd.Next(8) == 1); bool nullBirthday = (rnd.Next(8) == 2); bool nullCountry = (rnd.Next(8) == 3); bool nullEmail = (rnd.Next(8) == 4); table.AddRow((nullName ? null : personInfo.Name)); } m_TableView = new NTableGridView(); m_TableView.Grid.DataSource = new NDataSource(table); m_TableView.Grid.AllowEdit = true; return(m_TableView); }
protected override NWidget CreateExampleContent() { m_TableView = new NTableGridView(); // create a dummy data source with many columns to demonstrate horizontal scrolling NMemoryDataTable dataTable = new NMemoryDataTable(new NFieldInfo[] { // person info new NFieldInfo("Name-0", typeof(String)), new NFieldInfo("Gender-1", typeof(ENGender)), new NFieldInfo("Birthday-2", typeof(DateTime)), new NFieldInfo("Phone-3", typeof(String)), new NFieldInfo("Email-4", typeof(String)), // address info new NFieldInfo("Country-5", typeof(ENCountry)), new NFieldInfo("City-6", typeof(String)), new NFieldInfo("Address-7", typeof(String)), // product info new NFieldInfo("Product Name-8", typeof(String)), new NFieldInfo("Product Price-9", typeof(Double)), new NFieldInfo("Product Quantity-10", typeof(Int32)), }); for (int i = 0; i < 1000; i++) { NDummyDataSource.NPersonInfo personInfo = NDummyDataSource.RandomPersonInfo(); NDummyDataSource.NAddressInfo addressInfo = NDummyDataSource.RandomAddressInfo(); NDummyDataSource.NProductInfo productInfo = NDummyDataSource.RandomProductInfo(); dataTable.AddRow( // person info personInfo.Name, personInfo.Gender, personInfo.Birthday, personInfo.Phone, personInfo.Email, // address addressInfo.Country, addressInfo.City, addressInfo.Address, // product productInfo.Name, productInfo.Price, NDummyDataSource.RandomInt32(1, 100) ); } m_TableView.Grid.DataSource = new NDataSource(dataTable); return(m_TableView); }