var grid = new DataGrid({ id: 'grid', store: store, structure: layout, rowSelector: '20px', style: 'font-size:9pt', rowsPerPage: 1000, columnReordering: true, autoWidth: true, autoHeight: autoH});
public string WriteResult(DataTable dt) { DataGrid dg = new DataGrid(); dg.CellPadding = 5; dg.BackColor = System.Drawing.Color.White; dg.BorderColor = System.Drawing.Color.Gray; dg.Font.Name = "Arial"; dg.Font.Size = FontUnit.XSmall; dg.HeaderStyle.Font.Bold = true; dg.FooterStyle.Font.Bold = true; dg.DataSource = dt; dg.DataBind(); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); dg.RenderControl(hw); return sw.ToString(); }
public void ProcessRequest(System.Web.HttpContext context) { context.Response.Clear(); context.Response.ContentType = "text/plain"; //Instead of making a new DataGrid from scratch, you could also load an in-memory //instance of a page with the DataGrid on it. You'd then have to get the DataGrid from that page. DataGrid dg = new DataGrid(); //Set up your columns based on the form values here. //Instead of a DataTable, you could use any IEnumerable data source. DataTable dt = new DataTable(); dt.Columns.Add("TestCol"); DataRow dr = dt.NewRow(); dr["TestCol"] = context.Request.Form["myData"].ToString(); dt.Rows.Add(dr); dg.DataSource = dt; dg.DataBind(); //Create an in-memory target Page, then add your DataGrid to it. System.Web.UI.Page p = new System.Web.UI.Page(); p.Controls.Add(dg); //Create a StringWriter that will contain the HTML. //Execute the page, and voila, you got your rendered DataGrid. StringWriter writer = new StringWriter(); context.Server.Execute(p, writer, false); context.Response.Write(writer.ToString()); context.Response.End(); }
var grid = new DataGrid({ id: 'grid', structure: layout });
require( ["dojox/grid/DataGrid", "dojo/data/ObjectStore", "dojo/store/Memory", "dojo/domReady!"], function ( DataGrid, ObjectStore, Memory ) { var formsList = [ {id:1, name:"Jim", department:"accounting"}, {id:2, name:"Rosenblumentalovitsch", department:"engineering"}, {id:3, name:"Mike", department:"sales"}, {id:4, name:"John", department:"sales"} ]; formStore = new Memory( {data:formsList, idProperty:"id"} ); formGrid = new DataGrid( { store:dataStore = ObjectStore( {objectStore:formStore} ), query: {id: "*"} , structure:[ { name:"Form", field:"name", width:"100%" } ] }, "grid" ); formGrid.startup(); } );