private void AddControl(string tableName) { var control = BaseMainPage.LoadControl(Page, tableName); Url.UserControl = tableName; control.ID = tableName + _controls.Count; var accessControl = control as IAccessControl; if (ReadPermissions != null && !UserRoles.IsInAnyRoles(ReadPermissions)) { if (accessControl != null && !accessControl.CheckPermit(Page)) { var literal = new LiteralControl(Resources.SAccessDanied); PlaceHolder1.Controls.Add(literal); return; } } var sControl = control as ISelectedValue; if (sControl != null) { sControl.IsNew = Url.IsNew; sControl.IsRead = Url.IsRead; sControl.ShowHistory = Url.ShowHistory; sControl.IsSelect = Url.IsSelect; } PlaceHolder1.Controls.Add(control); _controls.Add(control); return; }
protected void BeforeStroreChanged(object sender, BeforeStoreChangedEventArgs e) { var json = e.DataHandler.JsonData; var dataHandler = new StoreDataHandler(json); var data = dataHandler.ObjectData <DIC_MySecondDictionary>(); var edit = (DIC_MySecondDictionaryEdit)BaseMainPage.LoadControl(Page, "DIC_MySecondDictionaryEdit"); var reloadData = false; bool isValid = true; e.Cancel = true; BeforeSaveValidate(data, ref isValid); if (!isValid) { foreach (var row in data) { X.AddScript($"setTimeout(function(){{ #{{store}}.getById({row.id}).setDirty(); }}, 100);"); } X.AddScript("#{grid}.view.loadMask.hide();"); return; } foreach (var row in data) { switch (e.Action) { case StoreAction.Update: // todo: подумать о том как показать ошибки reloadData |= edit.EditRowFromGrid(row); break; case StoreAction.Create: // todo: подумать о том как показать ошибки edit.InsertRowFromGrid(row); break; default: throw new ArgumentOutOfRangeException(); } } var result = source.View.GetSelect() .Where(r => data.Contains(r.Item)) .Select(source.View.GetFullModelDataExpression); if (reloadData) { store.Reload(); } else { e.ResponseRecords.AddRange(result); } X.AddScript("#{grid}.view.loadMask.hide();"); AfterSave(data.Select(r => r.id)); }
protected IFilterControl GetFilterControl(DBDataContext db) { SetFilterText(string.Empty, FilterHidden.Text); InitializeSelectedValues(); var filterControlInternal = (MyProductsFilter)FilterControlInternal ?? internalfilterControl; MainPageUrlBuilder pageUrlBuilder; if (filterControlInternal == null) { filterControlInternal = (MyProductsFilter)BaseMainPage.LoadControl(Page, GetDefaultFilterControl()); pageUrlBuilder = Url.Clone(); filterControlInternal.SetUrl(pageUrlBuilder); internalfilterControl = filterControlInternal; } else { pageUrlBuilder = Url; } filterControlInternal.SetDB(db); if (!FilterByParentControlIfExistsValue || ParentControlInternal.SelectedValue != null) { filterControlInternal.FilterByParentControl = FilterByParentControl; filterControlInternal.ParentControl = ParentControlInternal; } else { filterControlInternal.FilterByParentControl = null; filterControlInternal.ParentControl = null; } filterControlInternal.SelectedID = selectedID; filterControlInternal.ShowHistory = Url.ShowHistory; filterControlInternal.SelectedValues = SelectedValues; if (Url.GetFilter("MyProducts") == null && NavigatorControl.Values.MyProducts == null) { var defFilter = filterControlInternal.GetDefaultFilter(); FilterHidden.Text = defFilter; Url.SetFilter("MyProducts", defFilter); pageUrlBuilder.SetFilter("MyProducts", defFilter); Url.CreateUrl(); pageUrlBuilder.CreateUrl(); filterControlInternal.SetUrl(pageUrlBuilder); } InitializeFilterControl(filterControlInternal); if (filterPlaceHolder.ContentControls.Count == 0 && Url.ShowFilter) { filterPlaceHolder.Visible = true; filterPlaceHolder.ContentControls.Add(filterControlInternal); } return(filterControlInternal); }