public async Task <IActionResult> DataTableColEditor(string guid) { List <DataTableEditor> dataTableEditor = new List <DataTableEditor>(); if (guid != "") { Guid libGuid = Guid.Parse(guid); var fields = await _iField.FieldCollection(libGuid); DataTableEditor dtCol = new DataTableEditor(); foreach (Field field in fields) { if (field.Visible == 1) { dtCol = new DataTableEditor(); dtCol.label = field.Title; dtCol.name = field.Name.ToLower(); if (field.Visible == 1) { if (field.FieldType.Type.ToLower() == "datetime") { dtCol.type = "datetime"; dtCol.DisplayFormat = "MM/DD/YYYY"; } else if (field.FieldType.Type.ToLower() == "dropdown") { dtCol.type = "select"; await ColumnOptionsAsync(dtCol, field); } else if (field.FieldType.Type.ToLower() == "radiobutton") { dtCol.type = "radio"; await ColumnOptionsAsync(dtCol, field); } else { dtCol.type = "text"; } } else { dtCol.type = "hidden"; } if (field.Editable == 0) { dtCol.type = "hidden"; } dataTableEditor.Add(dtCol); } } } return(new JsonResult(new { result = dataTableEditor })); }
private static DataTableEditor CreateDataTableEditorFromDataTable(IQueryForm queryForm, DbCommandBuilder commandBuilder, DataTable dataTable, GetTableSchemaResult getTableSchemaResult, bool readOnly, ColorTheme colorTheme) { var editor = new DataTableEditor(queryForm, commandBuilder, colorTheme); editor.ReadOnly = readOnly; editor.DataTable = dataTable; editor.TableName = dataTable.TableName; editor.TableSchema = getTableSchemaResult; return(editor); }
private static DataTableEditor CreateDataTableEditorFromDataTable( DbCommandBuilder commandBuilder, DataTable dataTable, DataSet tableSchema, bool readOnly, ToolStripStatusLabel toolStripStatusLabel, ColorTheme colorTheme) { var editor = new DataTableEditor(commandBuilder, colorTheme); editor.ReadOnly = readOnly; editor.DataTable = dataTable; editor.TableName = dataTable.TableName; editor.TableSchema = tableSchema; editor.StatusBarPanel = toolStripStatusLabel; return editor; }
private async Task ColumnOptionsAsync(DataTableEditor dtCol, Field field) { var optionList = new List <DataTableColumnOption>(); optionList.Add(new DataTableColumnOption { value = "", label = "--Select--" }); if (!string.IsNullOrEmpty(field.LookupTable)) // if there is a lookup table take it first { var dependentField = await _iField.Find(Guid.Parse(field.LookUpId)); var dependentValue = await _iFieldValue.FindByFieldID(dependentField.ID); foreach (var item in dependentValue) { optionList.Add(new DataTableColumnOption { value = item.Value.Trim(), label = item.Value.Trim() }); } dtCol.options = optionList; } else // then check if the manual input for dropdown { if (!string.IsNullOrEmpty(field.DropdownValue)) { var dropItems = field.DropdownValue.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (dropItems.Length > 0) { foreach (string dropItem in dropItems) { optionList.Add(new DataTableColumnOption { value = dropItem.Trim(), label = dropItem.Trim() }); } dtCol.options = optionList; } } } }
private static void ShowWindow() { DataTableEditor dataTableWindow = EditorWindow.GetWindow <DataTableEditor>(true, "DataTable 工具"); dataTableWindow.minSize = new Vector2(1000, 600); }