Ejemplo n.º 1
0
 public string GetScript(String callbackName, String parameter, XafMenuItem menuItem, Boolean usePostBack)
 {
     if (Manager == null)
     {
         Manager = new XafCallbackManager();
     }
     return(Manager.GetScript(callbackName, String.Format("\"Action={0}\"", menuItem.Name), "", usePostBack).Replace("'", "\""));
 }
Ejemplo n.º 2
0
        public override void SetClientClickHandler(XafCallbackManager callbackManager, string controlID)
        {
            string clientScript = callbackManager.GetScript(controlID, string.Format("'{0}'", MenuItem.IndexPath), Action.GetFormattedConfirmationMessage(), IsPostBackRequired);

            clientClickHandler = string.Format("function(s, e) {{ {0}e.processOnServer = false;}}", clientScript);
            if (Control != null)
            {
                Control.Button.ClientSideEvents.Click = clientClickHandler;
            }
        }
Ejemplo n.º 3
0
        protected override object CreateControlsCore()
        {
            control = new XafBootstrapTable();
            control.ObjectTypeInfo = ObjectTypeInfo;
            control.ListView       = ListView;
            control.ObjectSpace    = ObjectSpace;
            control.ShowNumbers    = false;

            control.OnGenerateItemClick += new OnGenerateRowEventHandler(delegate(ref String Result, int RowNumber, object Row)
            {
                var key = GetMemberValue((Row as Object), collection.ObjectSpace.GetKeyPropertyName(Row.GetType()));
                if (!IsLookup)
                {
                    Result = String.Format(Result, XafCallbackManager.GetScript(control.ClientID, String.Format("'View={0}'", key)));
                }
                else
                {
                    Result = String.Format(Result, XafCallbackManager.GetScript(control.ClientID, String.Format("'Mark={0}'", key)));
                }
            });

            control.CustomColumns.Add(new XafBootstrapTable.HeaderInfo()
            {
                ID = "Selector", Align = "left", FieldName = "Selector", FixedWidth = 20
            });
            control.OnGenerateCell += new OnGenerateCellHandler(delegate(ref String Format, String FieldName, ref String value, int RowNumber, object data)
            {
                if (FieldName == "Selector" && control.ClientID != null)
                {
                    var key = GetMemberValue((data as Object), collection.ObjectSpace.GetKeyPropertyName(data.GetType()));
                    Format  = Format.Replace("<td ", String.Format("<td onclick=\"event.cancelBubble = true; {0}\" ", XafCallbackManager.GetScript(control.ClientID, String.Format("'Mark={0}'", key))));
                    value   = String.Format("<input type=\"checkbox\" {0}></label>",
                                            SelectedObjects.IndexOf((data as Object)) > -1 ? "checked" : ""
                                            );
                }
            });

            control.OnGenerateHeader += new OnGenerateHeaderHandler(delegate(ref String Format, String FieldName, ref String value, object data)
            {
                if (FieldName == "Selector" && control.ClientID != null)
                {
                    AllItemsChecked = Helpers.RequestManager.Request.Form[control.ClientID + "_CheckAll"] == "on";
                    Format          = Format.Replace("<th ", String.Format("<th onclick=\"event.cancelBubble = true; {0}\" ", XafCallbackManager.GetScript(control.ClientID, "'Mark=CheckAllChanged'")));
                    value           = String.Format("<input runat=\"server\" name=\"{1}_CheckAll\" type=\"checkbox\" {0}></label> ", (AllItemsChecked) ? "checked" : "", control.ClientID) + value;
                }
            });

            control.Init += control_Init;

            return(control);
        }
Ejemplo n.º 4
0
        protected override void OnViewControlsCreated()
        {
            base.OnViewControlsCreated();
            var gridListEditor = View.Editor as ASPxGridListEditor;

            if (gridListEditor != null && ((IModelListViewColumnChooserContextMenu)View.Model).ColumnChooserContextMenu)
            {
                XafCallbackManager.RegisterHandler(GetType().FullName, this);
                gridListEditor.Grid.FillContextMenuItems += GridOnFillContextMenuItems;
                var    script = XafCallbackManager.GetScript(GetType().FullName, "");
                string check  = "if (e.item.name == '" + ColumnChooserAction.Id + "') ";
                gridListEditor.Grid.ClientSideEvents.ContextMenuItemClick = $@"function(s, e){{{check}{script}}}";
            }
        }
Ejemplo n.º 5
0
        protected override void OnViewControlsCreated()
        {
            base.OnViewControlsCreated();
            if (((IModelListViewEventCreation)View.Model).CreateEventOnDoubleClick)
            {
                ASPxSchedulerListEditor editor = View.Editor as ASPxSchedulerListEditor;
                if (editor != null)
                {
                    XafCallbackManager.RegisterHandler("ASPxSchedulerEventCreationController", this);
                    editor.SchedulerControl.ClientSideEvents.Init = @"function(s,e) {
s.GetMainElement().ondblclick = function() { " + XafCallbackManager.GetScript("ASPxSchedulerEventCreationController", "") +
                                                                    @" }
}";
                }
            }
        }
Ejemplo n.º 6
0
        protected override void OnViewControlsCreated()
        {
            base.OnViewControlsCreated();
            XafCallbackManager callbackManager = ((ICallbackManagerHolder)WebWindow.CurrentRequestPage).CallbackManager;

            callbackManager.RegisterHandler(GetType().FullName, this);
            foreach (var action in Frame.Actions <SimpleAction>())
            {
                var modelActionClientScript = ((IModelActionClientScript)action.Model());
                if (!string.IsNullOrEmpty(modelActionClientScript?.ConfirmationMsg))
                {
                    var clientScript = callbackManager.GetScript(GetType().FullName, "ret +';" + action.Id + "'");
                    modelActionClientScript.Script = "var ret= confirm('" + modelActionClientScript.ConfirmationMsg + "'); " + clientScript;
                }
            }
        }
        private void CustomizeDashboardViewer(ASPxDashboard dashboardControl)
        {
            XafCallbackManager callbackManager = ((ICallbackManagerHolder)WebWindow.CurrentRequestPage).CallbackManager;

            callbackManager.RegisterHandler(HandlerName, this);
            string widgetScript = @"function getOid(s, e) {{
                                        function findMeasure(measure) {{
                                            return measure.DataMember === 'Oid';
                                        }}
                                        if (e.ItemName.includes('gridDashboardItem')) {{
                                             var axisPoint = e.GetAxisPoint();
                                             if (!axisPoint) 
                                                 return null;
                                             var itemData = e.GetData(),   
                                                dataSlice = itemData.GetSlice(axisPoint),
                                                oidMeasure = dataSlice.GetMeasures().find(findMeasure).Id,
                                                measureValue = dataSlice.GetMeasureValue(oidMeasure);
                                                {0}
                                        }}
                                    }}";

            dashboardControl.ClientSideEvents.ItemClick = string.Format(widgetScript, callbackManager.GetScript(HandlerName, "measureValue.GetValue()"));
        }
Ejemplo n.º 8
0
        protected override object CreateControlsCore()
        {
            control = base.CreateControlsCore() as XafBootstrapTable;
            var FirstModelVisibleColumn = ListView.Columns.Where(f => f.Index >= 0).OrderBy(f => f.Index).FirstOrDefault();

            if (FirstModelVisibleColumn != null)
            {
                control.OnGenerateCell += new OnGenerateCellHandler(delegate(ref String Format, String FieldName, ref String Value, int RowNumber, object data)
                {
                    if (data is ITreeNode)
                    {
                        var obj = (ITreeNode)data;
                        if (obj != null && FieldName == FirstModelVisibleColumn.Id)
                        {
                            int lvl = 0;
                            GetLevel(obj, ref lvl);
                            var spacing   = (lvl * 15);
                            var glyphicon = "";
                            if (obj is ITreeNodeGlyphicon)
                            {
                                glyphicon = (obj as ITreeNodeGlyphicon).Glyphicon;
                                if (String.Concat(glyphicon) != "")
                                {
                                    glyphicon = String.Format("<span class=\"{0}\"></span> ", glyphicon);
                                }
                            }

                            var expandScript = "<td onclick=\"if (!e) var e = event || window.event; var posX = $(this).offset().left; if (e.pageX - posX < 30 + " + spacing + ") {{{{ {0}; e.cancelBubble = true; }}}};\"";

                            if ((DataSource as IList).OfType <Object>().Where(f => (f as ITreeNode).Parent != null && (String.Concat(GetMemberValue((f as ITreeNode).Parent as Object, collection.ObjectSpace.GetKeyPropertyName(f.GetType()))) == String.Concat(GetMemberValue((obj as Object), collection.ObjectSpace.GetKeyPropertyName(obj.GetType()))))).Count() > 0)
                            {
                                if (GetExpanded(obj))
                                {
                                    Format = Format.Replace("<td ", String.Format(expandScript, XafCallbackManager.GetScript(control.ClientID, String.Format("'Expand={0}'", GetMemberValue((data as Object), collection.ObjectSpace.GetKeyPropertyName(data.GetType()))))));
                                    Value  = "</span><span class=\"glyphicon glyphicon-chevron-down glyphicon-sm\" > </span>" + glyphicon + Value;
                                }
                                else
                                {
                                    Format = Format.Replace("<td ", String.Format(expandScript, XafCallbackManager.GetScript(control.ClientID, String.Format("'Expand={0}'", GetMemberValue((data as Object), collection.ObjectSpace.GetKeyPropertyName(data.GetType()))))));
                                    Value  = "</span><span class=\"glyphicon glyphicon-chevron-right glyphicon-sm\" > </span>" + glyphicon + Value;
                                }
                            }
                            else
                            {
                                Value = "<span class=\"glyphicon glyphicon-sm\"></span> " + glyphicon + Value;
                            }

                            Value = "<span style=\"margin-left: " + (spacing) + "px\"></span>" + Value;
                        }
                        else
                        {
                            Boolean hasChildren = false;
                            foreach (var listObj in collection.List)
                            {
                                if ((listObj as ITreeNode).Parent == obj)
                                {
                                    hasChildren = true;
                                    break;
                                }
                            }
                            if (hasChildren)
                            {
                                if (HideGroupData && control.CustomColumns.Where(f => f.FieldName == FieldName).Count() == 0)
                                {
                                    Value = "";
                                }
                            }
                        }
                    }
                });
            }

            control.Init += Control_Init;

            return(control);
        }
Ejemplo n.º 9
0
        public void Refresh()
        {
            this.Controls.Clear();
            if (Page != null)
            {
                int       i          = 0;
                string    noImageUrl = ImageLoader.Instance.GetImageInfo("NoImage").ImageUrl;
                ArrayList list       = new ArrayList(dataSource);
                list.Sort(new PictureItemComparer());
                foreach (IPictureItem item in list)
                {
                    Table table = new Table();
                    table.Style["display"]        = "inline-block";
                    table.Style["vertical-align"] = "top";
                    this.Controls.Add(table);
                    table.BorderWidth = 0;
                    table.CellPadding = 5;
                    table.CellSpacing = 0;
                    table.Width       = Unit.Pixel(124);

                    ASPxCustomListEditorButton img = new ASPxCustomListEditorButton();
                    img.ID        = this.ID + "_" + (i++).ToString();
                    img.PictureID = item.ID;
                    if (item.Image != null)
                    {
                        string imageKey = "CLE_" + WebImageHelper.GetImageHash(item.Image);
                        img.ImageUrl = ImageResourceHttpHandler.GetWebResourceUrl(imageKey);
                        if (!images.ContainsKey(imageKey))
                        {
                            images.Add(imageKey, item.Image);
                        }
                    }
                    else
                    {
                        img.ImageUrl = noImageUrl;
                    }
                    img.Image.AlternateText = item.Text;
                    img.Image.Height        = 150;
                    img.Image.Width         = 104;
                    img.ToolTip             = item.Text;
                    img.EnableViewState     = false;
                    img.Paddings.Assign(new Paddings(new Unit(0)));
                    img.FocusRectPaddings.Assign(new Paddings(new Unit(0)));
                    img.AutoPostBack           = false;
                    img.ClientSideEvents.Click = "function(s, e) {" + (CallbackManager != null ? CallbackManager.GetScript(this.UniqueID, string.Format("'{0}'", img.PictureID)) : String.Empty) + "}";
                    TableCell cell = new TableCell();
                    cell.Controls.Add(img);
                    cell.Style["text-align"] = "center";
                    table.Rows.Add(new TableRow());
                    table.Rows[0].Cells.Add(cell);

                    Literal text = new Literal();
                    text.Text = item.Text;
                    cell      = new TableCell();
                    cell.Style["font-size"]  = "80%";
                    cell.Style["text-align"] = "center";
                    cell.Style["word-wrap"]  = "break-word";
                    cell.Style["word-break"] = "break-word";
                    cell.Controls.Add(text);
                    table.Rows.Add(new TableRow());
                    table.Rows[1].Cells.Add(cell);
                }
            }
        }
Ejemplo n.º 10
0
 public String GetScript(String parameter, String stringConfirmation = "", bool usePostBack = false)
 {
     return(XafCallbackManager.GetScript(CallbackID, parameter, stringConfirmation, usePostBack));
 }
Ejemplo n.º 11
0
        protected override object CreateControlsCore()
        {
            control = base.CreateControlsCore() as XafBootstrapTable;
            var FirstModelVisibleColumn = ListView.Columns.Where(f => f.Index >= 0).OrderBy(f => f.Index).FirstOrDefault();

            if (FirstModelVisibleColumn != null)
            {
                control.OnGenerateCell += new OnGenerateCellHandler(delegate(ref String Format, String FieldName, ref String Value, int RowNumber, object data)
                {
                    if (data is ITreeNode)
                    {
                        var obj = (ITreeNode)data;
                        if (obj != null && FieldName == FirstModelVisibleColumn.Id)
                        {
                            if ((DataSource as IList).OfType <Object>().Where(f => (f as ITreeNode).Parent != null && (String.Concat(GetMemberValue((f as ITreeNode).Parent as Object, collection.ObjectSpace.GetKeyPropertyName(f.GetType()))) == String.Concat(GetMemberValue((obj as Object), collection.ObjectSpace.GetKeyPropertyName(obj.GetType()))))).Count() > 0)
                            {
                                if (ExpandedItems.IndexOf(String.Concat(GetMemberValue((obj as Object), collection.ObjectSpace.GetKeyPropertyName(obj.GetType())))) > -1)
                                {
                                    Value = "</span><span class=\"glyphicon glyphicon-chevron-down glyphicon-sm\" onclick=\"" + XafCallbackManager.GetScript(control.ClientID, String.Format("'Expand={0}'", GetMemberValue((data as Object), collection.ObjectSpace.GetKeyPropertyName(data.GetType())))) + "event.cancelBubble = true;\"> </span>" + Value;
                                }
                                else
                                {
                                    Value = "</span><span class=\"glyphicon glyphicon-chevron-right glyphicon-sm\" onclick=\"" + XafCallbackManager.GetScript(control.ClientID, String.Format("'Expand={0}'", GetMemberValue((data as Object), collection.ObjectSpace.GetKeyPropertyName(data.GetType())))) + "event.cancelBubble = true;\"> </span>" + Value;
                                }
                            }
                            else
                            {
                                Value = "</span><span class=\"glyphicon glyphicon-sm\"> </span><span></span>" + Value;
                            }

                            int lvl = 0;
                            GetLevel(obj, ref lvl);
                            Value = "<span style=\"margin-left: " + (lvl * 10) + "px\">" + Value;
                        }
                        else
                        {
                            if (obj.Children.Count > 0)
                            {
                                if (HideGroupData && control.CustomColumns.Where(f => f.FieldName == FieldName).Count() == 0)
                                {
                                    Value = "";
                                }
                            }
                        }
                    }
                });
            }

            return(control);
        }
Ejemplo n.º 12
0
 void CurrentRequestWindow_PagePreRender(object sender, EventArgs e)
 {
     if (View != null)
     {
         ASPxPivotGridListEditor pivotGridListEditor = View.Editor as ASPxPivotGridListEditor;
         if (pivotGridListEditor != null)
         {
             ASPxPivotGrid pivotGrid = pivotGridListEditor.PivotGridControl;
             pivotGrid.ClientSideEvents.CellClick = String.Format("function(s, e){{{0}}}", XafCallbackManager.GetScript("ViewController1",
                                                                                                                        "e.ColumnIndex.toString() + ';' + e.RowIndex.toString()"
                                                                                                                        + " + ';' + e.ColumnValueType + ';' + e.RowValueType "));
         }
     }
 }