protected void ApplyReadOnlyOnControl(bool documentreadonly, TextInput input) { if (input.Controller != null) { if (input.Controller is CheckEdit) { input.Enabled = !documentreadonly; } } else { if (input is TextInputDropDown) { input.As <TextInputDropDown>().GetInput().readOnly = documentreadonly; } input.Readonly = documentreadonly; } }
public LayoutControl(string linkFieldName, TextInput input) : this(linkFieldName, input, "") { }
public LayoutControl(string linkFieldName, TextInput input, decimal percent = 1) : this(linkFieldName, input, "", percent) { }
public SearchLookupForm(SearchInput searchInput) : base() { if (searchInput.Content.parentElement != null && searchInput.Content.parentElement.parentElement != null) { PreviousScrollTop = searchInput.Content.parentElement.parentElement.scrollTop; ParentContainer = searchInput.Content.parentElement.parentElement; } var x = searchInput.Content.getBoundingClientRect(); MinHeight = 100; MinWidth = 150; var wid = searchInput.GetDropdownWidth(); if (wid < 150) { wid = 150; } Size = new Vector2(wid, 250); AllowSizeChange = true; SearchInput = searchInput; var frag = document.createDocumentFragment(); frag.AppendChildren( SearchEdit = new TextInput() { Text = searchInput.ClearOnOpen() ? "" : SearchInput.Text, OnFocusDontSelectAll = true, DisableFocusPopup = true, Bounds = new Vector4(4, 4, "(100% - 68px)", 20), ToolTip = new ToolTip("Help:", "[Enter] to Search, [CTRL] + [Enter] to Search and Use, [ESC] to close") }, btnSearch = new SimpleButton() { Text = "Search", Bounds = new Vector4("(100% - 65px)", 4, 61, 20), ItemClick = (s) => { SearchInput.OnRequestSearch(SearchEdit.Text, View); } }, View = new GridView(true, true) { AllowMultiSelection = false, UseEditForm = false, Bounds = new Vector4(4, 28, "(100% - 10px)", "(100% - 60px)") }, btnClose = new SimpleButton() { Text = "×", Bounds = new Vector4(4, "(100% - 25px)", 20, 20), ItemClick = (s) => { Close(); } }, btnNew = new SimpleButton() { Text = "New", Bounds = new Vector4("(100% - 65px)", "(100% - 25px)", 61, 20), ItemClick = (s) => { SearchInput.OnRequestNew(View); } }, btnUse = new SimpleButton() { Text = "Use", Bounds = new Vector4("(100% - 132px)", "(100% - 25px)", 61, 20), ItemClick = (s) => { if (View.FocusedDataHandle == -1 && View.RowCount() > 0) { View.FocusedDataHandle = 0; } if (FocusedRow != null) { SearchInput.OnAcceptResult(FocusedRow); this.Close(); } } }, btnClear = new SimpleButton() { Text = "Clear", Bounds = new Vector4("(100% - 199px)", "(100% - 25px)", 61, 20), ItemClick = (s) => { FocusedRow = null; SearchInput.OnAcceptResult(FocusedRow); this.Close(); } }); btnClose.Style.color = "red"; if (Helper.NotDesktop) { SearchEdit.Style.fontSize = "14px"; SearchEdit.Height = "45px"; btnSearch.Style.fontSize = "14px"; btnSearch.Height = 45; View.Top = 55; View.Height = "(100% - 112px)"; btnClear.Style.fontSize = "14px"; btnClear.Height = 45; btnClear.Top = "(100% - 51px)"; btnUse.Style.fontSize = "14px"; btnUse.Height = 45; btnUse.Top = "(100% - 51px)"; btnNew.Style.fontSize = "14px"; btnNew.Height = 45; btnNew.Top = "(100% - 51px)"; btnClose.Style.fontSize = "26px"; btnClose.Style.fontWeight = "bold"; btnClose.Height = 45; btnClose.Width = 61; btnClose.Top = "(100% - 51px)"; } SearchEdit.OnKeyDown = (obj, ev) => { if (ev.keyCode == 9) { Close(); ev.preventDefault(); } else if (ev.keyCode == 13) { SearchInput.OnRequestSearch(SearchEdit.Text, View); if (ev.ctrlKey) { btnUse.Content.click(); } ev.preventDefault(); } else if (ev.keyCode == 27) { FocusedRow = null; this.Close(); ev.preventDefault(); } }; View.OnFocusedRowChanged = (row, col) => { if (View.FocusedDataHandle > -1) { FocusedRow = View.DataSource[View.GetDataSourceRow(View.FocusedDataHandle)]; } else { FocusedRow = null; } SearchInput.OnAcceptResult(FocusedRow); if (SearchInput.FocusedChangeCloseForm) { this.Close(); } }; View.OnRowDoubleClick = (row) => { if (View.FocusedDataHandle > -1) { FocusedRow = View.DataSource[View.GetDataSourceRow(View.FocusedDataHandle)]; } else { FocusedRow = null; } SearchInput.OnAcceptResult(FocusedRow); this.Close(); }; this.Body.AppendChild(frag); SearchEdit.OnGotFocus = (obj) => { if (!string.IsNullOrWhiteSpace(SearchEdit.Text)) { SearchEdit.GetInput().selectionStart = (uint)SearchEdit.Text.Length; } }; LinkResize(View); }
public TextForm(TextInput input) : base() { if (input.Content.parentElement != null && input.Content.parentElement.parentElement != null) { PreviousScrollTop = input.Content.parentElement.parentElement.scrollTop; ParentContainer = input.Content.parentElement.parentElement; } WindowState = WindowStateType.Maximized; ReadInput = input; if (ReadInput is MemoInput) { EditInput = new MemoInput(); } else { EditInput = new TextInput(input.Type) { DisplayFormat = ReadInput.DisplayFormat }; EditInput.OnKeyDown = (s, ev) => { if (ev.keyCode == 13) { btnDone.Content.click(); } }; } EditInput.Text = input.Text; EditInput.Style.fontSize = "14px"; EditInput.DisableFocusPopup = true; EditInput.Size = new Vector2("(100% - 112px)", "100%"); EditInput.Location = new Vector2(0, 0); btnDone = new SimpleButton() { Text = "×", Bounds = new Vector4("(100% - 106px)", "(50% - 22.5px)", 100, 45), ItemClick = (sender) => { this.Close(); if (EditInput.GetEditValue() != ReadInput.GetEditValue()) { ReadInput.Text = EditInput.Text; if (ReadInput.IsSubmit) { dynamic jQuery2 = jQuery; dynamic e = jQuery2.Event("keypress"); e.which = 13; e.keyCode = 13; dynamic obj = jQuery.select((JQuery.TypeOrArray <Element>)ReadInput.Content); obj.trigger(e); //jQuery.select(ReadInput.Content).trigger((JQueryEventObject)e); } else if (ReadInput.GoNext) { var x = document.querySelectorAll("input, textarea, button"); int tabPlus1 = (int)ReadInput.Content.tabIndex + 1; for (int i = 0; i < x.length; i++) { if (x[i].As <HTMLElement>().tabIndex == tabPlus1) { x[i].As <HTMLElement>().FocusElement(); break; } } } } } }; btnDone.Style.borderRadius = "4px"; btnDone.ClassList.add("primary"); btnDone.Style.borderWidth = "0"; btnDone.Text = "×"; btnDone.Style.fontSize = "26px"; btnDone.Style.color = "white"; btnDone.Style.fontWeight = "bold"; EditInput.OnTextChanged = (sender) => { if (EditInput.GetEditValue() == ReadInput.GetEditValue()) { btnDone.Text = "×"; btnDone.Style.fontSize = "26px"; btnDone.Style.fontWeight = "bold"; } else { btnDone.Text = ReadInput.IsSubmit ? "Submit" : ReadInput.GoNext ? "Next" : "Done"; btnDone.Style.fontSize = "14px"; btnDone.Style.fontWeight = ""; } }; AppendChildren(EditInput, btnDone); }
private void GenerateForm() { this.Panel.Empty(); var length = GridView.ColumnCount(); int col = 0; int height = 25; int defaultHeight = 24 + 3 + 24 + 3; int defaultHeight2X = defaultHeight * 3; int incrementHeight = defaultHeight; int eachWidth = (350 / 3) - 3; for (int i = 0; i < length; i++) { incrementHeight = defaultHeight; var grCol = GridView.GetColumn(i); if (!grCol.AllowEdit) { continue; } var dtCol = grCol.Column; var dtIndex = grCol.GetDataColumnIndex(); if (grCol.Column.FieldName.ToLower() == "cntr") { grCol.ReadOnly = true; } switch (dtCol.DataType) { case DataType.DateTime: var lbldate = Label(grCol.Caption, 25 + (col * eachWidth + (col * 3)), height); var inputDate = new TextInput("date"); inputDate.SetBounds(25 + (col * eachWidth + (col * 3)), height + 16 + 3, eachWidth, 24); inputDate.SetDate(Convert.ToString(DataRow[dtIndex])); inputDate.Readonly = grCol.ReadOnly; if (!grCol.ReadOnly) { inputDate.OnTextChanged = (ev) => { DataRow[dtIndex] = inputDate.GetDate(); if (LiveData) { GridView.RenderGrid(); } }; } Panel.AppendChildren(lbldate, inputDate); break; case DataType.Integer: case DataType.Long: case DataType.Float: case DataType.Double: case DataType.Decimal: case DataType.Bool: case DataType.Byte: case DataType.Short: var lblnmb = Label(grCol.Caption, 25 + (col * eachWidth + (col * 3)), height); TextInput inputNum; if (grCol.CellDisplay is GridViewCellDisplayCheckBox) { inputNum = new TextInput("checkbox"); inputNum.SetChecked(DataRow[dtIndex]); } else { inputNum = new TextInput("number"); inputNum.Text = Convert.ToString(DataRow[dtIndex]); } inputNum.SetBounds(25 + (col * eachWidth + (col * 3)), height + 16 + 3, eachWidth, 24); inputNum.Readonly = grCol.ReadOnly; if (!grCol.ReadOnly) { inputNum.OnTextChanged = (ev) => { if (inputNum.Type == "checkbox") { DataRow[dtIndex] = inputNum.Text.IsTrue() == 1; } else { DataRow[dtIndex] = inputNum.Text; } if (LiveData) { GridView.RenderGrid(); } }; } Panel.AppendChildren(lblnmb, inputNum); break; default: case DataType.Object: case DataType.String: var lblstr = Label(grCol.Caption, 25 + (col * eachWidth + (col * 3)), height); var inputstr = new TextInput("text"); inputstr.SetBounds(25 + (col * eachWidth + (col * 3)), height + 16 + 3, eachWidth, 24); inputstr.Text = Convert.ToString(DataRow[dtIndex]); inputstr.Readonly = grCol.ReadOnly; if (!grCol.ReadOnly) { inputstr.OnTextChanged = (ev) => { DataRow[dtIndex] = inputstr.Text; if (LiveData) { GridView.RenderGrid(); } }; } Panel.AppendChildren(lblstr, inputstr); //if(obj.Length > 100) //{ // incrementHeight = defaultHeight2X; // col = 2; //} //else //{ //} break; } if (col == 2) { height += incrementHeight + 3; col = 0; } else { col++; } } // Add Accept Changes }