Introduction to TeeGrid & ASP.NET Core 2 MVC

TeeGrid for .NET Core renders to jsGrid grids for web pages, an open source project hosted on GitHub. See the jsGrid homepage, http://js-grid.com/. Source code for this demo here on Github

Learn more »

Basic Grid example.

We're calling the script from the page in this way:
/Home/GetGrid1



TeeGrid for NET Core derives from the Microsoft NetStandard Component.

Example accesses a data struct:

public void GetGrid1()
{
  //lock as a precaution
	lock (renderLock)
	{
		Steema.TeeGrid.WinForm.TGrid wGrid = new Steema.TeeGrid.WinForm.TGrid();

		List houses = new List();
		Random rnd = new Random();

		//test data
		for (int t = 0; t < 100; t++)
		{
			houses.Add(new THouse() { Address = t.ToString() + rnd.Next(1, 100).ToString() + " St", Floors = rnd.Next(1, 10) });
		}

		//apply data to grid
		wGrid.Data = new Steema.TeeGrid.Data.Reflection.VirtualListData(houses);

		string gridscript = wGrid.Grid.Export.JSGrid.AsString(false, true);

		byte[] array = System.Text.Encoding.ASCII.GetBytes(gridscript);

		Response.Body.Write(array, 0, array.Length);
	}
}

Data format:

public struct THouse
{
	public string Address { get; set; }
	public int Floors { get; set; }
}

System.Data.DataTable

TeeGrid here accesses a System.Data.DataTable. The original data for this example has been sourced via json input and an array of Base64 images. They have been commbined in a strongly-typed table.

example code:

DataTable stronglyTyped = StronglyTyped(myTable);

Steema.TeeGrid.NetCore.TGrid wGrid = new Steema.TeeGrid.NetCore.TGrid();

Steema.TeeGrid.Themes.GridThemes.iOS.ApplyTo(wGrid.Grid);

wGrid.DataSource = stronglyTyped;
wGrid.Grid.Export.JSGrid.Width = "100%";

string gridscript = wGrid.Grid.Export.JSGrid.AsString(false, true);

byte[] array = System.Text.Encoding.ASCII.GetBytes(gridscript);

Response.Body.Write(array, 0, array.Length);

© 2018 - Steema Software SL