private void AddNewRows(int numRows) { if (this.DataSource is BusinessObjectDataSource) { BusinessObjectDataSource ds = this.DataSource as BusinessObjectDataSource; ds.AddNewRows(numRows); } }
public KeyValuePair <GridView, ImageButton> BuildGrid(Func <IEnumerable <Caisis.BOL.IBusinessObject> > datasource, Action <Caisis.BOL.IBusinessObject> adder, XElement metadata, string name) { string tablename = metadata.Name.LocalName; BusinessObjectDataSource ods = new BusinessObjectDataSource(metadata, datasource, adder); ods.ID = tablename + "_ODS"; // init CaisisGridView CaisisSimpleGridView grid = new CaisisSimpleGridView(); grid.ShowDeleteButton = false; grid.EnableViewState = true; grid.RowCreated += new GridViewRowEventHandler((o, e) => ods.IncrementRowIndex()); // grid.DataSourceID = ods.ID; grid.DataSource = ods; grid.ID = tablename + "_CGV"; grid.AutoGenerateColumns = false; grid.Visible = true; grid.AllowSorting = false; grid.AllowPaging = false; //grid.HorizontalAlign = HorizontalAlign.Center; //grid.EditButtonID = "EditBtn"; grid.TotalBlankRows = 20; // TODO: metadata support grid.VisibleBlankRows = 3; // TODO: metadata support // add columns // grid.DataKeyNames = new string[] { primaryKeyName, foreignKeyNames, ... }; List <string> dataKeys = new List <string> { Caisis.BOL.BusinessObject.GetPrimaryKeyName(tablename) }; dataKeys.AddRange(Caisis.BOL.BusinessObject.GetForeignKeyNames(tablename)); grid.DataKeyNames = dataKeys.ToArray(); // foreach visible field, add CaisisDataBoundField(ICaisisInputControl) to grid.Columns GetColumns(metadata, tablename, dataKeys, ods.FetchCurrentBusinessObject).ForEach(f => grid.Columns.Add(f)); // TODO: we need access to the grid container // add image button ImageButton addNewRowBtn = new ImageButton(); addNewRowBtn.ImageUrl = "../../Images/DataGridAddNewRow.gif"; addNewRowBtn.ID = grid.ID + "_NewRow"; addNewRowBtn.CssClass = "dataGridImageButton"; grid.AddButtonId = addNewRowBtn.ID; // attach addBtn modifier to appropriate grid event (OnLoad?) grid.Load += new EventHandler((o, e) => { addNewRowBtn.OnClientClick = "var grid = document.getElementById('" + grid.ID + "'); if(grid.showNextRow) {return grid.showNextRow(); } else { return true; }"; }); return(new KeyValuePair <GridView, ImageButton>(grid, addNewRowBtn)); }
public void UpdateDataSource(DataSourceBase dataSource, DataSourceInfo newDataSourceInfo) { var newDataSource = new BusinessObjectDataSource { Name = newDataSourceInfo.Name, ReferenceName = newDataSourceInfo.Name }; CreateDataSourceProperties(newDataSource, newDataSourceInfo.Schema); UpdateCollectionItem(Report.Dictionary.DataSources, dataSource, newDataSource); RefreshReport(); }
private static void CreateDataSourceProperties(Column parent, DataSchema schema) { foreach (var property in schema.Properties) { var propertyName = property.Key; var propertySchema = property.Value; Column propertyColumn; if (propertySchema.Type == SchemaDataType.Object) { propertyColumn = new Column { Name = propertyName, ReferenceName = propertyName, DataType = typeof(object) }; CreateDataSourceProperties(propertyColumn, propertySchema); } else if (propertySchema.Type == SchemaDataType.Array) { propertyColumn = new BusinessObjectDataSource { Name = propertyName, ReferenceName = propertyName }; CreateDataSourceProperties(propertyColumn, propertySchema.Items); } else { propertyColumn = new Column { Name = propertyName, ReferenceName = propertyName, DataType = DataTypes[propertySchema.Type] }; } parent.Columns.Add(propertyColumn); } }