private void gridView_Load(object sender, EventArgs e)
        {
            ASPxGridView gridView   = (ASPxGridView)sender;
            string       AdjustSize = String.Format(" var height = Math.max(0, document.documentElement.clientHeight) - 170; {0}.SetHeight(height);", gridView.ClientInstanceName);

            ClientSideEventsHelper.AssignClientHandlerSafe(gridView, "Init", string.Format("function(s,e){{{0}}}", GetAdjustSizeScript(gridView)), "GridViewInitEventHandler");
        }
 private void UpdatePageControl(ASPxPageControl pageControl)
 {
     //loop through PageControl's tabs
     foreach (TabPage tab in pageControl.TabPages)
     {
         //remove the item count from the tab caption
         tab.Text = DetailViewControllerHelper.ClearItemCountInTabCaption(tab.Text);
         var listPropertyEditor = View.FindItem(tab.Name) as ListPropertyEditor;
         if (listPropertyEditor != null)
         {
             var count = listPropertyEditor.ListView.CollectionSource.GetCount();
             if (count > 0)
             {
                 tab.Text += " (" + count + ")";
             }
             if (listPropertyEditor.ListView.Editor is ASPxGridListEditor editor && editor.Grid != null)
             {
                 //Assign the ASPxClientGridView.EndCallback event hander. This is required for inline editing
                 editor.Grid.JSProperties["cpCaption"] = tab.Text;
                 ClientSideEventsHelper.AssignClientHandlerSafe(editor.Grid, "EndCallback", $"function(s, e) {{ " +
                                                                $"if (!s.cpCaption) return;" +
                                                                $"var tab = {pageControl.ClientInstanceName}.GetTabByName('{tab.Name}');" +
                                                                $"tab.SetText(s.cpCaption);" +
                                                                $"delete s.cpCaption}}", nameof(EmployeeDetailViewWebController));
             }
         }
     }
 }
 private void AddClientSideFunctionalityCore(ASPxWebControl dxControl)
 {
     if (dxControl != null)
     {
         EventHandler loadEventHandler = (s, e) => {
             ASPxWebControl control = (ASPxWebControl)s;
             ClientSideEventsHelper.AssignClientHandlerSafe(control, "GotFocus", @"
                 function (s,e){
                     if (s.inputElement!=null)
                         window.lastFocusedEditorId = s.inputElement.id;
                 }", Guid.NewGuid().ToString());
             ClientSideEventsHelper.AssignClientHandlerSafe(control, "Init", @"            
                 function (s,e){
                     if (s.inputElement!=null && window.lastFocusedEditorId === s.inputElement.id) {
                         var timeout = window.setTimeout(function () {
                             var element = document.getElementById(s.inputElement.id);
                             element.focus();
                             element.selectionStart = element.selectionEnd = 10000;
                             clearTimeout(timeout);
                         }, 500);
                     }
                 }", Guid.NewGuid().ToString());
         };
         EventHandler disposedEventHandler = null;
         disposedEventHandler = (s, e) => {
             ASPxWebControl control = (ASPxWebControl)s;
             control.Disposed -= disposedEventHandler;
             control.Load     -= loadEventHandler;
         };
         dxControl.Disposed += disposedEventHandler;
         dxControl.Load     += loadEventHandler;
     }
 }
        private void ConfigureCascade(ASPxComboBox comboBox)
        {
            var filterLookup = FilterLookupScript();

            if (filterLookup != null)
            {
                ClientSideEventsHelper.AssignClientHandlerSafe(comboBox, nameof(comboBox.ClientSideEvents.ValueChanged),
                                                               $"function(s,e){{{filterLookup}}}", $"{GetType().FullName}{nameof(ConfigureCascade)}{nameof(comboBox.ClientSideEvents.ValueChanged)}");
            }
        }
Esempio n. 5
0
 private void AssignClientHandler(object sender, string eventName)
 {
     foreach (var editor in ((WebPropertyEditor)sender).GetEditors())
     {
         ClientSideEventsHelper.AssignClientHandlerSafe(editor, eventName, @"
         function (s,e){
             console.log(s.GetText());
             s.inputElement.value=s.inputElement.value.toUpperCase();
         }", Guid.NewGuid().ToString());
     }
 }
        void IParentViewPropertyEditor.SetParentView(ObjectView value)
        {
            _parentView = value;
            if (value is ListView listView)
            {
                var gridListEditor = ((ASPxGridListEditor)listView.Editor);

                ClientSideEventsHelper.AssignClientHandlerSafe(gridListEditor.Grid,
                                                               nameof(gridListEditor.Grid.ClientSideEvents.BeginCallback),
                                                               $"function(s,e){{ClearEditorItems('{_clientStorage}','{View}')}}",
                                                               $"{GetType().FullName}{nameof(gridListEditor.Grid.ClientSideEvents.BeginCallback)}");
            }
        }
        private void ConfigureSynchronize(ASPxComboBox comboBox)
        {
            var lookupCascadePropertyEditor = Model.GetParent <IModelObjectView>().VisibleMemberViewItems()
                                              .Cast <IModelMemberViewItemLookupCascadePropertyEditor>().FirstOrDefault(_ => _.LookupCascade.CascadeMemberViewItem == Model && _.LookupCascade.Synchronize);

            if (lookupCascadePropertyEditor != null)
            {
                var filterColumnIndex = comboBox.Columns.OfType <ListBoxColumn>().ToArray().FindIndex(column => column.FieldName == lookupCascadePropertyEditor.LookupCascade.CascadeColumnFilter.Id);
                var cascadeMember     = lookupCascadePropertyEditor.GetParent <IModelMemberViewItem>();
                ClientSideEventsHelper.AssignClientHandlerSafe(comboBox, nameof(comboBox.ClientSideEvents.ValueChanged),
                                                               $"function(s,e){{SynchronizeLookupValue(s,'{cascadeMember.GetLookupListView().Id}','{_parentView.Id}','{filterColumnIndex}','{cascadeMember.ModelMember.Type.FullName}')}}",
                                                               $"{GetType().FullName}{nameof(ConfigureSynchronize)}{nameof(comboBox.ClientSideEvents.ValueChanged)}");
            }
        }
Esempio n. 8
0
        protected override void OnViewControlsCreated()
        {
            base.OnViewControlsCreated();

            CallbackManager.RegisterHandler(handlerId, this);

            ASPxPivotGridListEditor pivotGridListEditor = View.Editor as ASPxPivotGridListEditor;

            if (pivotGridListEditor != null)
            {
                ASPxPivotGrid pivotGrid = pivotGridListEditor.PivotGridControl;
                string        script    = CallbackManager.GetScript(handlerId, "e.ColumnIndex + ';' + e.RowIndex");
                ClientSideEventsHelper.AssignClientHandlerSafe(pivotGrid, "CellClick", "function(s, e) {" + script + "}", "pivotGrid.CellClick");
            }
        }
        protected override void OnViewControlsCreated()
        {
            base.OnViewControlsCreated();

            ASPxGridListEditor gridListEditor = View.Editor as ASPxGridListEditor;

            gridListEditor.BatchEditModeHelper.CustomUpdateBatchValue += BatchValueIsUpdated;

            string Grid_BatchEditStartEditingKey = "BatchEditStartEditingKey";

            ClientSideEventsHelper.AssignClientHandlerSafe(gridListEditor.Grid, "BatchEditStartEditing",
                                                           BatchEditStartEditing, Grid_BatchEditStartEditingKey);

            string Grid_BatchEditEndEditingKey = "BatchEditEndEditingKey";

            ClientSideEventsHelper.AssignClientHandlerSafe(gridListEditor.Grid, "BatchEditEndEditing",
                                                           BatchEditEndEditing, Grid_BatchEditEndEditingKey);
        }
        protected override void OnViewControlsCreated()
        {
            base.OnViewControlsCreated();
            //ASPxGridListEditor listEditor = ((ListView)View).Editor as ASPxGridListEditor;
            //if (listEditor != null)
            //{
            //    listEditor.Grid.SettingsPager.Mode = DevExpress.Web.GridViewPagerMode.ShowAllRecords;
            //    listEditor.Grid.Settings.VerticalScrollBarMode = DevExpress.Web.ScrollBarMode.Auto;
            //    listEditor.Grid.Width = new System.Web.UI.WebControls.Unit("100%");
            //    //listEditor.Grid.
            //}

            ASPxGridListEditor gridListEditor = ((ListView)View).Editor as ASPxGridListEditor;

            if (gridListEditor != null)
            {
                ASPxGridView gridView = gridListEditor.Grid;
                gridView.Load += gridView_Load;
                gridView.Width = Unit.Percentage(100);
                gridView.Settings.VerticalScrollBarMode = ScrollBarMode.Auto;
                gridView.ClientInstanceName             = "grid_" + View.Id;
                //foreach (WebColumnBase column in gridView.Columns)
                //{
                //    IColumnInfo columnInfo = ((IDataItemTemplateInfoProvider)gridListEditor).GetColumnInfo(column);
                //    if (columnInfo != null)
                //    {
                //        IModelColumn modelColumn = (IModelColumn)columnInfo.Model;
                //        column.Width = Unit.Percentage(modelColumn.Width);
                //    }
                //}
                ASPxGlobalEvents globalEvents = new ASPxGlobalEvents();
                globalEvents.ID = "GE1";
                string adjustSizeScript = GetAdjustSizeScript(gridView);
                globalEvents.ClientSideEvents.ControlsInitialized = string.Format("function(s,e){{ ASPxClientUtils.AttachEventToElement(window, 'resize', function(evt) {{{0}}}); }}", adjustSizeScript);
                ClientSideEventsHelper.AssignClientHandlerSafe(gridView, "EndCallback", string.Format("function(s,e){{{0}}}", adjustSizeScript), "EndCallbackEventHandler");
                ((Control)View.Control).Controls.Add(globalEvents);
            }
            // Access and customize the target View control.
        }
        private void CurrentRequestWindow_PagePreRender(object sender, EventArgs e)
        {
            if (View == null)
            {
                return;
            }
            DashboardViewItem sourceItem = (DashboardViewItem)View.FindItem(FilterSourceID);

            if (sourceItem.InnerView == null)
            {
                return;
            }
            ListView           listView = (ListView)sourceItem.InnerView;
            ASPxGridListEditor editor   = (ASPxGridListEditor)listView.Editor;

            if (editor == null)
            {
                return;
            }
            ICallbackManagerHolder holder = (ICallbackManagerHolder)WebWindow.CurrentRequestPage;
            string script = holder.CallbackManager.GetScript();

            script = string.Format(CultureInfo.InvariantCulture, @"
function(s, e) {{
    if(e.isChangedOnServer){{
        {0}
    }}else{{
        var xafCallback = function() {{
            s.EndCallback.RemoveHandler(xafCallback);
            {0}
        }};
        s.EndCallback.AddHandler(xafCallback);
    }}
}}
                ", script);
            ClientSideEventsHelper.AssignClientHandlerSafe(editor.Grid, "SelectionChanged", script, "DashboardRefreshController");
        }