/// <summary> /// Set a string value to a cell in a row. /// </summary> /// <param name="row"></param> /// <param name="column"></param> /// <param name="cellValue"></param> /// <returns></returns> public bool SetCellValue(IGridRow row, IGridColumn column, string cellValue) { if (row == null || column == null || cellValue == null) { return(false); } // find the cell in the row, matching the column IGridCell cell = row.ListCell.Where(ce => ce.Column == column).FirstOrDefault(); if (cell == null) { return(false); } // the cell must be string GridCellString cellValueString = cell as GridCellString; if (cellValueString == null) { return(false); } cellValueString.Content = cellValue; return(true); }
private String GetValueFor(IGridRow row) { Object value; try { if (RenderValue != null) { value = RenderValue(row.Model as T); } else { value = ExpressionValue(row.Model as T); } } catch (NullReferenceException) { return(String.Empty); } if (value == null) { return(String.Empty); } if (Format == null) { return(value.ToString()); } return(String.Format(Format, value)); }
/// <summary> /// Create a cell (for a row), depending on the column type. /// </summary> /// <param name="column"></param> /// <returns></returns> public IGridCell CreateCell(IDynDataGrid dataGrid, IGridColumn column, IGridRow row) { // create a cell matching the type of the column IGridColumnString colString = column as IGridColumnString; if (colString != null) { // set a default value return(new GridCellString(colString, row, "", dataGrid.GridCellChangedProvider)); } //IGridColumnInt colInt = column as GridColumnInt; //if (colInt != null) //{ // // set a default value // return new GridCellInt(colInt, 0); //} IGridColumnCheckBox colCheckBox = column as IGridColumnCheckBox; if (colCheckBox != null) { return(new GridCellCheckBox(colCheckBox, row, false, dataGrid.GridCellChangedProvider)); } throw new Exception("Factory.CreateCell(): type not yet implemented."); }
public override IHtmlContent ValueFor(IGridRow <object> row) { object value = GetValueFor(row); if (value == null) { return(HtmlString.Empty); } if (value is IHtmlContent) { return(value as IHtmlContent); } if (FormatExpression != null) { Format = FormatExpression.Invoke((T)row.Model); } if (RouteValues != null) { Format = $"<a href=\"{RouteValues.Invoke((T)row.Model)}\">{Format}</a>"; } if (Format != null) { value = string.Format(Format, value); } if (IsEncoded) { return(new HtmlString(HtmlEncoder.Default.Encode(value.ToString()))); } return(new HtmlString(value.ToString())); }
public virtual IHtmlString ValueFor(IGridRow <Object> row) { Object value = GetValueFor(row); if (value == null) { return(MvcHtmlString.Empty); } if (value is IHtmlString content) { return(content); } if (Format != null) { value = String.Format(Format, value); } if (IsEncoded) { return(new HtmlString(WebUtility.HtmlEncode(value.ToString()))); } return(new HtmlString(value.ToString())); }
public virtual IHtmlContent ValueFor(IGridRow <Object> row) { Object?value = ColumnValueFor(row); if (value == null) { return(HtmlString.Empty); } if (value is IHtmlContent content) { return(content); } if (Format != null) { value = String.Format(Format, value); } if (IsEncoded) { return(new GridHtmlString(value.ToString())); } return(new HtmlString(value.ToString())); }
/// <summary> /// Add a row data model to the grid UI, create a corresponding VM. /// The grid row must have cells. /// Use this method when you map your application dataGrid model to this component dataGrid model. /// </summary> /// <param name="gridRow"></param> /// <returns></returns> public IGridRowVM AddRow(IGridRow gridRow) { if (gridRow == null) { return(null); } // check the cells (basic check: just the number of cells) if (gridRow.ListCell.Count() != _collColumnGrid.Count) { return(null); } // the row should be present in the dataGrid model if (!_dynDataGrid.ListRow.Contains(gridRow)) { return(null); } // add it to the view: create VM IGridRowVM rowVM = new GridRowVM(gridRow); _collDataRow.Add(rowVM); RaisePropertyChanged("CollDataRow"); return(rowVM); }
/// <summary> /// Set a bool value to a cell in a row. /// The cell can be a bool, a checkButton or a radioButton. /// </summary> /// <param name="row"></param> /// <param name="column"></param> /// <param name="cellValue"></param> /// <returns></returns> public bool SetCellValue(IGridRow row, IGridColumn column, bool cellValue) { if (row == null || column == null) { return(false); } // find the cell in the row, matching the column IGridCell cell = row.ListCell.Where(ce => ce.Column == column).FirstOrDefault(); if (cell == null) { return(false); } // the cell must be a bool: can be checkbox, a radioButton GridCellCheckBox cellValueBool = cell as GridCellCheckBox; if (cellValueBool != null) { cellValueBool.Content = cellValue; return(true); } // TODO: others types: radioButton return(false); }
private void CreateDataGrid(IDynDataGridFactory dynDataGridFactory) { DataGrid = new DynDataGrid(); //----create columns IGridColumn columnKey; dynDataGridFactory.CreateColumn(DataGrid, GridColumnType.String, "Key", out columnKey); // this column cells are read-only columnKey.IsEditionReadOnly = true; IGridColumn columnValue; dynDataGridFactory.CreateColumn(DataGrid, GridColumnType.String, "Value", out columnValue); // col checkbox IGridColumn columnCheck; dynDataGridFactory.CreateColumn(DataGrid, GridColumnType.CheckBox, "Checked", out columnCheck); //----create a data row, with empty cells IGridRow row = DynDataGridFactory.CreateRowWithCells(DataGrid); //----create data cells DataGrid.SetCellValue(row, columnKey, "keyYes"); DataGrid.SetCellValue(row, "Value", "Oui"); // checked by default DataGrid.SetCellValue(row, "Checked", true); // test: search a column by the name //IGridColumn colFound = DataGrid.FindColumnByName("Key"); }
public bool AddRow(IGridRow row) { // check if the row columns match the datagrid columns // TODO: _listRow.Add(row); return(true); }
public GridCellBase(IGridColumn column, IGridRow row, GridCellChangedProvider actionProvider) { Column = column; Row = row; _gridCellChangedProvider = actionProvider; IsReadOnly = column.IsEditionReadOnly; }
public override IHtmlString ValueFor(IGridRow row) { String value = GetValueFor(row); if (IsEncoded) { value = WebUtility.HtmlEncode(value); } return(new HtmlString(value)); }
/// <summary> /// Set a bool value to a cell in a row. /// The cell can be a bool, a checkButton or a radioButton. /// </summary> /// <param name="row"></param> /// <param name="colName"></param> /// <param name="cellValue"></param> /// <returns></returns> public bool SetCellValue(IGridRow row, string colName, bool cellValue) { // find the column IGridColumn colum = _listColumn.Where(c => c.Name.Equals(colName)).FirstOrDefault(); if (colum == null) { return(false); } return(SetCellValue(row, colum, cellValue)); }
/// <summary> /// A grid cell content has changed. /// </summary> /// <param name="cell"></param> private void GridCellChanged(IGridCell cell) { // coming here when a cell value is modified in the UI! // TODO: // get the row and the column where is placed the cell IGridRow row = cell.Row; IGridColumn column = cell.Column; // TODO: add your code here!! FootPageText = cell.Content.ToString(); RaisePropertyChanged("FootPageText"); }
private Object GetValueFor(IGridRow <Object> row) { try { if (RenderValue != null) { return(RenderValue(row.Model as T)); } return(ExpressionValue(row.Model as T)); } catch (NullReferenceException) { return(null); } }
public override IHtmlContent ValueForKey(IGridRow <object> row) { object value = GetValueFor(row); if (value == null) { return(HtmlString.Empty); } if (value is IHtmlContent) { return(value as IHtmlContent); } if (IsEncoded) { return(new HtmlString(HtmlEncoder.Default.Encode(value.ToString()))); } return(new HtmlString(value.ToString())); }
private object GetValueFor(IGridRow <object> row) { try { if (RenderValue != null) { return(RenderValue(row.Model as T)); } if (ExpressionValue != null) { return(ExpressionValue(row.Model as T)); } return(row.Model.GetType().GetProperty(Name).GetValue(row.Model, null)); } catch (NullReferenceException) { return(null); } }
private Object GetValueFor(IGridRow <Object> row) { try { if (RenderValue != null) { return(RenderValue(row.Model as T)); } Type type = Nullable.GetUnderlyingType(typeof(TValue)) ?? typeof(TValue); if (type.GetTypeInfo().IsEnum) { return(GetEnumValue(type, ExpressionValue(row.Model as T).ToString())); } return(ExpressionValue(row.Model as T)); } catch (NullReferenceException) { return(null); } }
private Object?ColumnValueFor(IGridRow <Object> row) { try { if (RenderValue != null) { return(RenderValue((T)row.Model, row.Index)); } Type type = Nullable.GetUnderlyingType(typeof(TValue)) ?? typeof(TValue); if (type.IsEnum) { return(EnumValue(type, ExpressionValue((T)row.Model) !.ToString() !)); } return(ExpressionValue((T)row.Model)); } catch (NullReferenceException) { return(null); } }
public abstract IHtmlString ValueFor(IGridRow <Object> row);
/// <summary> /// Constructor. /// Provide the default (its a bool ). /// </summary> /// <param name="column"></param> /// <param name="value"></param> public GridCellCheckBox(IGridColumnCheckBox column, IGridRow row, bool value, GridCellChangedProvider actionProvider) : base(column, row, actionProvider) { Content = value; }
public abstract IHtmlContent ValueForKey(IGridRow <object> row);
public abstract IHtmlString ValueFor(IGridRow row);
public abstract IHtmlContent ValueFor(IGridRow <Object> row);
// remove the row from the datagrid public bool RemoveRow(IGridRow row) { _listRow.Remove(row); return(true); }
public GridCellString(IGridColumnString column, IGridRow row, string value, GridCellChangedProvider actionProvider) : base(column, row, actionProvider) { Content = value; }
public GridRowVM(IGridRow gridRow) { GridRow = gridRow; }