internal static string GenerateGrid(string gridName, out int statusCode, NameValueCollection nameValueCollection = null) { if (nameValueCollection == null) { nameValueCollection = new NameValueCollection(); } statusCode = 200; IMVCGridDefinition grid = MVCGridDefinitionTable.GetDefinitionInterface(gridName); QueryOptions options = QueryStringParser.ParseOptions(grid, nameValueCollection); GridContext gridContext = MVCGrid.NetCore.Utility.GridContextUtility.Create(/*context, */ gridName, grid, options); GridEngine engine = new GridEngine(); if (!engine.CheckAuthorization(gridContext)) { //Forbidden statusCode = 403; return(string.Empty); } IMVCGridRenderingEngine renderingEngine = GridEngine.GetRenderingEngine(gridContext); // TODO: Reimplement this for csv exports and other rendering responses. //renderingEngine.PrepareResponse(context.Response); StringBuilder sb = new StringBuilder(); TextWriter htmlWriter = new StringWriter(sb); engine.Run(renderingEngine, gridContext, htmlWriter); string html = sb.ToString(); return(html); }
/// <summary> /// Set up the grid-engines locally /// </summary> private void SetupGrid() { _log.InfoFormat("Setting up grid..."); for (int i = 0; i < NUM_ENGINES; i++) { IComputeEngine engine = new GridEngine(); engine.TaskBroker = _taskBrokerClient; _engines.Add(engine); ServiceHost host = new ServiceHost(engine); host.Description.Endpoints[0].Address = new EndpointAddress(String.Format(@"{0}/{1}" , host.BaseAddresses[0].AbsoluteUri , engine.EngineId)); _engineHosts.Add(host); try { host.Open(); _log.InfoFormat("Started grid engine with id: {0}", engine.EngineId); } catch (Exception e) { _log.ErrorFormat("Exception: {0}\n{1}", e.Message, e.StackTrace); host.Abort(); _engineHosts.Remove(host); } } _log.InfoFormat("Grid setup complete."); }
/// <summary> /// binding Custom collection to the GridGroupingControl. /// </summary> private void SampleCustomization() { CustomerCollection customers = PopulateCustomers.CreateCustomers(); this.groupingGrid1.DataSource = customers; GridEngine engine = this.groupingGrid1.Engine; engine.TopLevelGroupOptions.ShowCaption = true; GridRelationDescriptorCollection relations = new GridRelationDescriptorCollection(); // First level GridRelationDescriptor rd = AddRelation("Level_0", relations); // Subsequent levels for (int level = 1; level < 5; level++) { rd = AddRelation("Level_" + level.ToString(), rd.ChildTableDescriptor.Relations); } this.groupingGrid1.TableDescriptor.Relations = relations; Syncfusion.Grouping.Diagnostics.IterateThroughNestedDisplayElement(this.groupingGrid1.Table); }
private void HandleTable(HttpContext context) { string gridName = context.Request["Name"]; //StringBuilder sbDebug = new StringBuilder(); //foreach (string key in context.Request.QueryString.AllKeys) //{ // sbDebug.Append(key); // sbDebug.Append(" = "); // sbDebug.Append(context.Request.QueryString[key]); // sbDebug.Append("<br />"); //} var grid = MVCGridDefinitionTable.GetDefinitionInterface(gridName); var options = GridOptionParser.ParseOptions(grid, gridName, context.Request); var gridContext = GridContextUtility.Create(context, gridName, grid, options); GridEngine engine = new GridEngine(); if (!engine.CheckAuthorization(gridContext)) { //Forbidden context.Response.StatusCode = 403; context.Response.End(); return; } IMVCGridRenderingEngine renderingEngine = GridEngine.GetRenderingEngine(gridContext); renderingEngine.PrepareResponse(context.Response); engine.Run(renderingEngine, gridContext, context.Response.Output); }
internal static IHtmlString MVCGrid(this HtmlHelper helper, string name, IMVCGridDefinition grid, object pageParameters) { GridEngine ge = new GridEngine(); ControllerContext context = helper.ViewContext.Controller.ControllerContext; string html = ge.GetBasePageHtml(/*helper, */ HttpContext.Current.Request.QueryString, name, grid, pageParameters); return(MvcHtmlString.Create(html)); }
internal static IHtmlString MVCGrid(this HtmlHelper helper, string name, IMVCGridDefinition grid, object pageParameters, QueryOptions options = null) { GridEngine ge = new GridEngine(); string html = ge.GetBasePageHtml(helper, name, grid, pageParameters, options); return(MvcHtmlString.Create(html)); }
internal static IHtmlContent MVCGridNetCore <TModel>(this IHtmlHelper <TModel> helper, string name, IMVCGridDefinition grid, object pageParameters) { GridEngine ge = new GridEngine(); string html = ge.GetBasePageHtml(name, grid, pageParameters); return(new HtmlString(html)); }
public override void OnStart(GridEngine engine) { this.engine = engine; MovementTile.GenerateUVRectFromCost = MovementCostToUVRect; engine.MovementGrid.ForEachTile(tile => tile.UpdateCost(CalculateMovementCost(tile.Coordinate))); //engine.MovementGrid.ForEachTile(tile => PaintTileBasedOnMovementCost(tile)); }
/// <summary> /// MVCs the grid. /// </summary> /// <param name="helper">The helper.</param> /// <param name="name">The name.</param> /// <param name="grid">The grid.</param> /// <param name="pageParameters">The page parameters.</param> /// <returns>IHtmlString.</returns> /// TODO Edit XML Comment Template for MvcGrid internal static IHtmlString MvcGrid( this HtmlHelper helper, string name, IMvcGridDefinition grid, object pageParameters) { var ge = new GridEngine(); var html = ge.GetBasePageHtml(helper, name, grid, pageParameters); return(MvcHtmlString.Create(html)); }
private void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e) { GridGroupingControl groupingControl = (GridGroupingControl)sender; Element el = e.TableCellIdentity.DisplayElement; e.Style.CellTipText = el.GetType().Name + (el.ParentElement != null ? " (Parent: " + el.ParentElement.GetType().Name + ")" : ""); if (el is ExtraSection) { if (e.Style.TableCellIdentity.ColIndex == 0) { // Row Header e.Style.CellType = ((GridTableDescriptor)el.ParentTableDescriptor).Appearance.RecordRowHeaderCell.CellType; if (el == el.ParentTable.CurrentElement) { e.Style.Text = "#"; } } else if (e.Style.TableCellIdentity.ColIndex <= el.GroupLevel) { // Group Indent e.Style.BackColor = Color.FromArgb(218, 229, 245); } else if (e.Style.TableCellIdentity.ColIndex <= extraSectionCoverCols + el.ParentTableDescriptor.GroupedColumns.Count) { // Covered area (see TableModel_QueryCoveredRange above) e.Style.BackColor = Color.FromArgb(192, 201, 219); e.Style.CellValue = "ExtraSection (" + el.ParentGroup.Name + ")"; } else if (e.Style.TableCellIdentity.ColIndex > 3) { e.Style.BackColor = Color.FromArgb(252, 172, 38); // you can get the column as follows: GridTable table = (GridTable)el.ParentTable; GridTableDescriptor td = e.TableCellIdentity.Table.TableDescriptor; GridColumnDescriptor column = td.RecordRowColumns[0, e.Style.TableCellIdentity.ColIndex - el.ParentTableDescriptor.GroupedColumns.Count - 1]; e.Style.CellValue = column.Name; // Using that column you could try and identify the summary that should be displayed in this cell. if (column.MappingName == "Freight") { // Calling this method to demonstrate different alternatives to get to the summary text e.Style.Text = GetSummaryText(el.ParentGroup, "SummaryRow 1", "FreightAverage"); // Easier is to simple call built-in routine: e.Style.Text = GridEngine.GetSummaryText(el.ParentGroup, "SummaryRow 1", "FreightAverage"); } } } }
/// <summary> /// Grouping sample Customizations are done here. /// </summary> private void SampleCustomization() { //Create Instance for GridEngine GridEngine eng = this.gridGroupingControl1.Engine; //Instantiate the eventTracer eventTracer = new EngineEventTracer(eng, this.listView1); //Set the GroupDropPanel Height this.gridGroupingControl1.GroupDropPanel.Height += 10; //Hook the Mouse_Down event of the Listview this.listView1.MouseDown += new MouseEventHandler(listView1_MouseDown); }
public IActionResult Grid() { string gridName = HttpContext.Request.Query["Name"]; IMVCGridDefinition grid = MVCGridDefinitionTable.GetDefinitionInterface(gridName); QueryOptions options = QueryStringParser.ParseOptions(grid, HttpHelper.HttpContext.Request.ToNameValueCollection()); GridContext gridContext = GridContextUtility.Create(/*context, */ gridName, grid, options); GridEngine engine = new GridEngine(); if (!engine.CheckAuthorization(gridContext)) { return(new StatusCodeResult(403)); } var renderingModel = engine.GenerateModel(gridContext); return(PartialView(grid.ViewPath, renderingModel)); }
public ActionResult Grid() { HttpContext context = System.Web.HttpContext.Current; string gridName = context.Request.QueryString["Name"]; IMVCGridDefinition grid = MVCGridDefinitionTable.GetDefinitionInterface(gridName); QueryOptions options = QueryStringParser.ParseOptions(grid, context.Request.QueryString); GridContext gridContext = GridContextUtility.Create(/*context, */ gridName, grid, options); GridEngine engine = new GridEngine(); if (!engine.CheckAuthorization(gridContext, context.User.Identity.IsAuthenticated)) { return(new HttpStatusCodeResult(403, "Access denied")); } var renderingModel = engine.GenerateModel(gridContext); return(PartialView(grid.ViewPath, renderingModel)); }
private void Gc1_SourceListListChangedCompleted(object sender, TableListChangedEventArgs e) { var r = this.gc1.TableModel.RowCount; var p = this.gc1.TableModel.Rows.Model.RowCount; GridSummaryRow rec = this.gc1.Table.DisplayElements[r] as GridSummaryRow; GridRecordRow row = this.gc1.Table.DisplayElements[r] as GridRecordRow; if (row is GridRecordRow) { MessageBox.Show("row"); } if (rec is GridSummaryRow) { foreach (var scd in rec.SummaryRowDescriptor.SummaryColumns) { if (scd.Name == "Machine Hours Remaining") { txtMachine.Text = GridEngine.GetSummaryText(rec.ParentGroup, scd); } else if (scd.Name == "Weld Hours Remaining") { txtWeld.Text = GridEngine.GetSummaryText(rec.ParentGroup, scd); } else if (scd.Name == "Build Hours Remaining") { txtBuild.Text = GridEngine.GetSummaryText(rec.ParentGroup, scd); } else if (scd.Name == "Tracker Hours Remaining") { txtTrackers.Text = GridEngine.GetSummaryText(rec.ParentGroup, scd); } else if (scd.Name == "Design Hours Remaining") { txtDesign.Text = GridEngine.GetSummaryText(rec.ParentGroup, scd); } } } }
public ActionResult Grid() { var context = System.Web.HttpContext.Current; string gridName = context.Request["Name"]; var grid = MVCGridDefinitionTable.GetDefinitionInterface(gridName); var options = GridOptionParser.ParseOptions(grid, gridName, context.Request); var gridContext = GridContextUtility.Create(context, gridName, grid, options); GridEngine engine = new GridEngine(); if (!engine.CheckAuthorization(gridContext)) { return(new HttpStatusCodeResult(403, "Access denied")); } var renderingModel = engine.GenerateModel(gridContext); return(PartialView(grid.ViewPath, renderingModel)); }
/// <summary> /// Handles the table. /// </summary> /// <param name="context">The context.</param> /// TODO Edit XML Comment Template for HandleTable private static void HandleTable(HttpContext context) { var gridName = context.Request["Name"]; var grid = MvcGridDefinitionTable.GetDefinitionInterface(gridName); var options = QueryStringParser.ParseOptions(grid, context.Request); var gridContext = GridContextUtility.Create(context, gridName, grid, options); var engine = new GridEngine(); if (!engine.CheckAuthorization(gridContext)) { context.Response.StatusCode = 403; context.Response.End(); return; } var renderingEngine = GridEngine.GetRenderingEngine(gridContext); renderingEngine.PrepareResponse(context.Response); engine.Run(renderingEngine, gridContext, context.Response.Output); }
/// <summary> /// Current cell tracing events and set the dataset to the GridGroupingControl /// </summary> private void SampleCustomization() { GridEngine eng = this.gridGroupingControl1.Engine; eventTracer = new EngineEventTracer(eng, this.Output); this.eventTracer.HookCurrentCellEvents(); String commandstring1 = "select * from Categories"; String commandstring2 = "select * from Products"; SqlCeDataAdapter da1 = new SqlCeDataAdapter(commandstring1, connString); SqlCeDataAdapter da2 = new SqlCeDataAdapter(commandstring2, connString); try { da1.Fill(dataset11, "Categories"); da2.Fill(dataset11, "Products"); } catch (SqlException ex) { ShowErrorMessage(ex); } }
/// <summary> /// Setting Maual relation to the GridGroupingControl. /// </summary> private void SampleCustomization() { #region DataTable DataSet ds = new DataSet(); ReadXml(ds, @"Expand.xml"); ds.Tables[1].TableName = "Products"; ds.Tables[2].TableName = "OrderDetails"; ds.Tables[3].TableName = "Suppliers"; ds.Relations.Add( ds.Tables[0].Columns["CategoryID"], ds.Tables[1].Columns["CategoryID"]); ds.Relations[0].RelationName = "Category_Products"; ds.Relations.Add( ds.Tables[1].Columns["ProductID"], ds.Tables[2].Columns["ProductID"]); ds.Relations[1].RelationName = "Products_OrderDetails"; #endregion this.groupingGrid1.DataSource = ds.Tables[0]; GridEngine engine = this.groupingGrid1.Engine; engine.TopLevelGroupOptions.ShowCaption = true; // Record summary for Categories Tables GridTableDescriptor categoriesTableDescriptor = (GridTableDescriptor)engine.TableDescriptor; categoriesTableDescriptor.Columns.Clear(); categoriesTableDescriptor.Columns.Add("CategoryID"); categoriesTableDescriptor.Columns.Add("CategoryName"); categoriesTableDescriptor.Columns.Add("Description"); categoriesTableDescriptor.Columns["CategoryName"].Width = 200; //Creating a new SummaryColumnDescriptor. GridSummaryColumnDescriptor countCat = new GridSummaryColumnDescriptor("RecordCount"); //Setting it's properties. countCat.SummaryType = SummaryType.Count; countCat.Style = GridSummaryStyle.FillRow; //Initializing it to the Column it is associated with. countCat.DataMember = "CategoryID"; //Mentioning the format of display. countCat.Format = " {Count} Records."; //Adding the SummaryColumnDescriptor to the SummaryRowDescriptor. GridSummaryRowDescriptor categoriesSummaryRow = new GridSummaryRowDescriptor("RecordCountRow"); categoriesSummaryRow.SummaryColumns.Add(countCat); //Adding the SummaryRowDescriptor to the TableDesriptor. categoriesTableDescriptor.SummaryRows.Add(categoriesSummaryRow); // Group Products table by "SupplierID" RelationDescriptor productsRelationDescriptor = categoriesTableDescriptor.Relations["Products"]; GridTableDescriptor productsTableDescriptor = (GridTableDescriptor)productsRelationDescriptor.ChildTableDescriptor; productsTableDescriptor.GroupedColumns.Add("SupplierID"); // Group OrderDetails table by "Discount" // Add Total = "[UnitPrice]*[Quantity]" expression field // Add Summaries for Total and Average for UnitPrice. RelationDescriptor orderDetailsRelationDescriptor = productsTableDescriptor.Relations["OrderDetails"]; GridTableDescriptor orderDetailsTableDescriptor = (GridTableDescriptor)orderDetailsRelationDescriptor.ChildTableDescriptor; ExpressionFieldDescriptor ed = new ExpressionFieldDescriptor("Total", "[UnitPrice]*[Quantity]"); ed.DefaultValue = ""; orderDetailsTableDescriptor.ExpressionFields.Add(ed); orderDetailsTableDescriptor.GroupedColumns.Add("Discount"); //Adding the SummaryColumnDescriptor to the SummaryRowDescriptor. GridSummaryRowDescriptor orderDetailsSummaryRow = new GridSummaryRowDescriptor("Total"); orderDetailsTableDescriptor.SummaryRows.Add(orderDetailsSummaryRow); //Creating a new SummaryColumnDescriptor. GridSummaryColumnDescriptor totalSum = new GridSummaryColumnDescriptor("Total"); //Setting it's properties. totalSum.SummaryType = SummaryType.DoubleAggregate; totalSum.Style = GridSummaryStyle.Column; //Initializing it to the Column it is associated with. totalSum.DataMember = "Total"; totalSum.DisplayColumn = "Total"; totalSum.Format = "Sum={Sum}"; orderDetailsSummaryRow.SummaryColumns.Add(totalSum); orderDetailsTableDescriptor.Columns["Total"].Width = 70; //Creating a new SummaryColumnDescriptor. GridSummaryColumnDescriptor avgUnitPrice = new GridSummaryColumnDescriptor("AvgUnitPrice"); //Setting it's properties. avgUnitPrice.SummaryType = SummaryType.DoubleAggregate; avgUnitPrice.Style = GridSummaryStyle.Column; avgUnitPrice.DataMember = "UnitPrice"; avgUnitPrice.DisplayColumn = "UnitPrice"; avgUnitPrice.Format = "Avg={Average:#.0}"; orderDetailsSummaryRow.SummaryColumns.Add(avgUnitPrice); // expand a specific record, search for groups etc. Table categoriesTable = engine.Table;//.RelatedTables["Categories"]; Console.WriteLine(categoriesTable.ToString()); Table productsTable = categoriesTable.RelatedTables["Products"]; Console.WriteLine(productsTable.ToString()); // Get the child table in the products table that is assocuated with category "1" ChildTable product1 = (ChildTable)productsTable.TopLevelGroup.Groups["1"]; Console.WriteLine(product1.ToString()); Console.WriteLine(product1.Groups[0].ToString()); // Get the child table in the products table that is assocuated with category "1" ChildTable product21 = (ChildTable)productsTable.TopLevelGroup.Groups["8"]; Console.WriteLine(product21.ToString()); Console.WriteLine(product21.Groups[0].Records[0].ToString()); // Show me the associated "NestedTable" element of the categories table (the NestedTable // element established the link between parent table and a nested child table) Console.WriteLine(product21.Groups[0].Records[0].ParentChildTable.ParentNestedTable); // Expand the product for category 8 product21.IsExpanded = true; product21.ParentNestedTable.IsExpanded = true; product21.ParentNestedTable.ParentRecord.IsExpanded = true; // When you assign a "DataSet" as a datasource, the DataSet is a list with one record (not allowing AddNew) with nested tables. // Expand the first record so that tables are shown. engine.Table.TopLevelGroup.Records[0].IsExpanded = true; // Sort product table by ProductName product21.ParentTable.TableDescriptor.SortedColumns.Add("ProductName"); // Find group for supplier id 21 Group supplier21Group = product21.Groups["21"]; // Find productname Spegesild in that group int index = supplier21Group.Records.FindRecord("Spegesild"); // Print out the row index and record index Record r = supplier21Group.Records[index]; Console.WriteLine("Found: " + r.ToString()); Console.WriteLine("RowIndex " + engine.Table.NestedDisplayElements.IndexOf(r).ToString()); Console.WriteLine("Record Index " + engine.Table.Records.IndexOf(r).ToString()); // Dump out nested display elements to console this.groupingGrid1.Table.Records[0].IsExpanded = true; this.groupingGrid1.Table.TopLevelGroup.IsExpanded = true; engine.ChildGroupOptions.ShowCaption = true; engine.NestedTableGroupOptions.ShowCaption = true; // Adding GroupDropAreas for nested tables. groupingGrid1.AddGroupDropArea((GridTable)productsTable); groupingGrid1.AddGroupDropArea((GridTable)productsTable.RelatedTables[0]); groupingGrid1.ShowGroupDropArea = true; //Navigate to other control using tabkey navigation groupingGrid1.WantTabKey = false; // Make Spegesild current record if (r != null) { r.SetCurrent(); // Expand record and nested tables r.IsExpanded = true; r.NestedTables[0].IsExpanded = true; Record orderDetailsRecords = r.NestedTables[0].ChildTable.GetFirstRecord(); // Expand Group record belongs to orderDetailsRecords.ParentGroup.IsExpanded = true; // Scroll this record in view. groupingGrid1.TableControl.ScrollInView(orderDetailsRecords); groupingGrid1.TableControl.LeftColIndex = 1; } }
public EngineEventTracer(GridEngine groupingEngine, ListView output) { this.output = output; this.groupingEngine = groupingEngine; }
public virtual void OnUpdate(GridEngine engine) { }
public override void OnStart(GridEngine engine) { this.engine = engine; engine.PlantGrid.ForEachTile(TryGrowTree); }
public virtual void OnEnd(GridEngine engine) { }
public Tracer(GridEngine groupingEngine, EventTracer Output) { this.etracer = Output; this.etracer.Enabled = true; this.groupingEngine = groupingEngine; }
public virtual void OnStart(GridEngine engine) { }