示例#1
0
 public static string Formatter(int row, int cell, object value, Column columnDef, object dataContext)
 {
     OptionSetValue opt = (OptionSetValue)value;
     return opt == null ? "" : opt.Name;
             
             
 }
示例#2
0
 public static Column BindReadOnlyColumn(Column column)
 {
     column.Formatter = Formatter;
     NumberFormatInfo numberFormatInfo = NumberEx.GetCurrencyEditFormatInfo();
     column.Options = numberFormatInfo;
     return column;
 }
示例#3
0
 public static Column BindColumnWithOptions(Column column, OptionSetBindingOptions options)
 {
     column.Editor = EditorFactory;
     column.Formatter = Formatter;
     column.Options = options;
     return column;
 }
示例#4
0
 public static Column BindColumn(Column column)
 {
     column.Editor = TimeEditor;
     column.Formatter = Formatter;
     column.Options =OrganizationServiceProxy.UserSettings.TimeFormatString;
     return column;
 }
示例#5
0
 public static Column BindReadOnlyColumn(Column column, int precision)
 {
     column.Formatter = XrmNumberEditor.Formatter;
     NumberFormatInfo numberFormatInfo = NumberEx.GetNumberFormatInfo();
     numberFormatInfo.Precision = precision;
     column.Options = numberFormatInfo;
     return column;
 }
示例#6
0
 public static string Formatter(int row, int cell, object value, Column columnDef, object dataContext)
 {
     if (value != null)
     {
         return (string)value;
     }
     else
         return "";
 }
示例#7
0
 // Formatter to format number
 public static string Formatter(int row, int cell, object value, Column columnDef, object dataContext)
 {
     if (value != null)
     {
         Number numeric = (Number)value;
         return NumberEx.Format(numeric,(NumberFormatInfo)columnDef.Options);
     }
     else
         return "";
 }
示例#8
0
 public static Column BindColumn(Column column, int minValue, int maxValue)
 {
     column.Editor = MoneyEditor;
     column.Formatter = Formatter;
     NumberFormatInfo numberFormatInfo = NumberEx.GetCurrencyEditFormatInfo();
     numberFormatInfo.MinValue = minValue;
     numberFormatInfo.MaxValue = maxValue;
     column.Options = numberFormatInfo;
     return column;
 }
示例#9
0
 public static Column BindColumn(Column column, int minValue, int maxValue, int precision)
 {
     column.Editor = NumberEditor;
     column.Formatter = XrmNumberEditor.Formatter;
     NumberFormatInfo numberFormatInfo = NumberEx.GetNumberFormatInfo();
     numberFormatInfo.MinValue = minValue;
     numberFormatInfo.MaxValue = maxValue;
     numberFormatInfo.Precision = precision;
     column.Options = numberFormatInfo;
     return column;
 }
示例#10
0
 public static Column BindColumn(Column column, string entityLogicalName, string attributeLogicalName, bool allowEmpty)
 {
     column.Editor = EditorFactory;
     column.Formatter = Formatter;
     OptionSetBindingOptions opts = new OptionSetBindingOptions();
     opts.attributeLogicalName = attributeLogicalName;
     opts.entityLogicalName = entityLogicalName;
     opts.allowEmpty = allowEmpty;
     column.Options = opts;
     return column;
 }
示例#11
0
 // Formatter to show a lookup with hyperlink
 public static string Formatter(int row, int cell, object value, Column columnDef, object dataContext)
 {
     if (value != null)
     {
         //TOOO: Add an onlclick handler to the grid to handle the lookup links
         EntityReference entityRef = (EntityReference)value;
         return "<a href='#' class='sparkle-lookup-link' entityid='" + entityRef.Id +"' typename='" + entityRef.LogicalName + "'>" + XmlHelper.Encode(entityRef.Name) +"</a>";
     }
     else
         return "";
 }
示例#12
0
        public static Column BindReadOnlyColumn(Column column, string TrueOptionDisplayName, string FalseOptionDisplayName)
        {
            column.Formatter = XrmBooleanEditor.Formatter;

            BooleanBindingOptions opts = new BooleanBindingOptions();
            opts.TrueOptionDisplayName = TrueOptionDisplayName;
            opts.FalseOptionDisplayName = FalseOptionDisplayName;
            column.Options = opts;

            return column;
        }
示例#13
0
 public static string DefaultFormatter(int row, int cell, object value, Column columnDef, object dataContext)
 {
     if (value == null)
     {
         return "";
     }
     else
     {
         return value.ToString().Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;");
     }
 }
示例#14
0
        // Formatter to format number
        public static string Formatter(int row, int cell, object value, Column columnDef, object dataContext)
        {
            if (value != null)
            {

                string currencySymbol = getCurrencySymbol((EntityReference)((EntityBuiltInAttributes)dataContext).TransactionCurrencyId);
                Money numeric = (Money)value;
                return currencySymbol + " " + NumberEx.Format(numeric.Value, (NumberFormatInfo)columnDef.Options);
            }
            else
                return "";
        }
示例#15
0
        public static string GroupCellFormatter(int row, int cell, object value, Column columnDef, object dataContext)
        {
            Group item = (Group)dataContext;

            string indentation = (item.Level * 15).ToString() + "px";
            return "<span class='slick-group-toggle " +
                (item.Collapsed ? "collapsed" : "expanded") +
                "' style='margin-left:" + indentation + "'>" +
                "</span>" +
                "<span class='slick-group-title' level='" + item.Level + "'>" +
                  item.Title +
                "</span>";
        }
示例#16
0
 public static ItemMetaData GetGroupRowMetadata(object item)
 {
     ItemMetaData metaData = new ItemMetaData();
      metaData.Selectable = false;
      metaData.Focusable = true;
      metaData.CssClasses =  "slick-group";
      metaData.Columns = new List<Column>();
      Column col = new Column();
      metaData.Columns.Add(col);
      col.ColSpan = "*";
      col.Formatter = GroupCellFormatter;
      col.Editor = null;
      return metaData;
 }
 public static Column AddColumn(List<Column> cols, string displayName, int width, string field)
 {
     Column col = new Column();
     col.Id = field;
     col.Name = displayName; // TODO: Multi-language
     col.Field = field;
     col.Width = width;
     col.Options = true;
     col.MaxWidth = width;
     col.MinWidth = width;
     col.Sortable = true;
     ArrayEx.Add(cols, col);
     return col;
 }
        public static string RenderCardColumnCell(int row, int cell, object value, Column columnDef, object dataContext)
        {
            List<Column> columns = (List<Column>)columnDef.Options;
            Entity record = (Entity)dataContext;
            string cardHtml = "";
            bool firstRow = true;
            string imageUrl = record.GetAttributeValueString("card_image_url");
            string imageHtml;
            if (imageUrl != null)
            {
                imageHtml = @"<img class='entity-image' src='" + Page.Context.GetClientUrl() + imageUrl + @"'/>";
            }
            else
            {
                string typeName = record.LogicalName;
                if (typeName=="activitypointer")
                {
                    string activitytypecode = record.GetAttributeValueString("activitytypecode");
                    typeName = activitytypecode;
                }
                imageHtml = @"<div class='record_card " + typeName + @"_card'><img src='..\..\sparkle_\css\images\transparent_spacer.gif'\></dv>";
            }

            // Only show the first 3 columns from the Quick Find View
            int rowIndex = 0;
            cardHtml = "<table class='contact-card-layout'><tr><td>" + imageHtml +"</td><td>";
            foreach (Column col in columns)
            {
                if (col.Field != "activitytypecode")
                {
                    object fieldValue = record.GetAttributeValue(col.Field);
                    string dataFormatted = col.Formatter(row, cell, fieldValue,col, dataContext);

                    cardHtml += "<div " + (firstRow ? "class='first-row'" : "") + " tooltip='" + fieldValue + "'>" + dataFormatted + "</div>";
                    firstRow = false;
                    rowIndex++;
                }
                if (rowIndex > 3)
                    break;
            }
            cardHtml += "</tr></table>";
            return cardHtml;
        }
示例#19
0
        public static string GetDateFormat(Column columnDef)
        {
            string dateFormat = GetDateBindingOptions(columnDef).OverrideUserDateFormat;

            if (dateFormat == null && OrganizationServiceProxy.UserSettings != null)
            {
                dateFormat = OrganizationServiceProxy.UserSettings.DateFormatString;
            }

            return dateFormat;
        }
示例#20
0
        public static string SumTotalsFormatter(Dictionary<string,object> totals, Column columnDef) {

            Dictionary<string, object> sum = (Dictionary<string, object>)totals["sum"];

            float? val = (sum != null) ? (float?)sum[columnDef.Field] : null;
            if (val != null)
            {
                return "avg: " + Math.Round(val).ToString() + " %" ;
            }
            return "";
            
        }
 public static Column BindColumn(Column column, Action<string, Action<EntityCollection>> queryCommand, string idAttribute, string nameAttribute, string typeCodeAttribute)
 {
     column.Editor = LookupEditor;
     XrmLookupEditorOptions currencyLookupOptions = new XrmLookupEditorOptions();
     currencyLookupOptions.queryCommand = queryCommand;
     currencyLookupOptions.idAttribute = idAttribute;
     currencyLookupOptions.nameAttribute = nameAttribute;
     currencyLookupOptions.typeCodeAttribute = typeCodeAttribute;
     column.Options = currencyLookupOptions;
     column.Formatter = XrmLookupEditor.Formatter;
     return column;
 }
示例#22
0
 public static string FormatterDateOnly(int row, int cell, object value, Column columnDef, object dataContext)
 {
     string dateFormat = (string)columnDef.Options;
     if (OrganizationServiceProxy.UserSettings != null)
     {
         dateFormat = OrganizationServiceProxy.UserSettings.DateFormatString;
     }
     DateTime dateValue = (DateTime)value;
     return DateTimeEx.FormatDateSpecific(dateValue, dateFormat);
 }
示例#23
0
 public static Column BindReadOnlyColumn(Column column, bool dateOnly)
 {
     column.Formatter = FormatterDateOnly;
     return column;
 }
        public static string ColumnFormatter(int row, int cell, object value, Column columnDef, object dataContext)
        {
            string typeName;
            string returnValue = String.Empty;

            if (columnDef.DataType != null)
                typeName = columnDef.DataType;
            else
                typeName =  value.GetType().Name;

            Entity entityContext = (Entity)dataContext;
            bool unchanged = (entityContext.EntityState==null) || (entityContext.EntityState == EntityStates.Unchanged);

            // If unchanged we can get values from the formatted values
            if (unchanged && entityContext.FormattedValues!=null && entityContext.FormattedValues.ContainsKey(columnDef.Field+"name"))
            {
                returnValue = entityContext.FormattedValues[columnDef.Field + "name"];
                return returnValue;
            }
            if (value != null)
            {
                switch (typeName.ToLowerCase())
                {

                    case "string":
                        returnValue = value.ToString();
                        break;
                    case "boolean":
                    case "bool":
                        returnValue = value.ToString();
                        break;
                    case "dateTime":
                    case "date":
                        DateTime dateValue = (DateTime)value;
                        string dateFormat = "dd/mm/yy";
                        string timeFormat = "hh:MM";
                        if (OrganizationServiceProxy.UserSettings != null)
                        {
                            dateFormat = OrganizationServiceProxy.UserSettings.DateFormatString;
                            timeFormat = OrganizationServiceProxy.UserSettings.TimeFormatString;
                        }
                        returnValue = DateTimeEx.FormatDateSpecific(dateValue, dateFormat) + " " + DateTimeEx.FormatTimeSpecific(dateValue, timeFormat);
                        break;
                    case "decimal":
                        returnValue = value.ToString();
                        break;
                    case "double":
                        returnValue = value.ToString();
                        break;
                    case "int":
                        returnValue = value.ToString();
                        break;
                    case "guid":
                        returnValue = value.ToString();
                        break;
                    case "money":
                        Money moneyValue = (Money)value;

                        returnValue = moneyValue.Value.ToString();
                        break;
                    case "customer":
                    case "owner":
                    case "lookup":
                    case "entityreference":
                        EntityReference refValue = (EntityReference)value;
                        returnValue = @"<a class=""sparkle-grid-link"" href=""#"" logicalName=""" + refValue.LogicalName + @""" id=""" + refValue.Id + @""">" + refValue.Name + "</a>";
                        break;
                    case "picklist":
                    case "status":
                    case "state":
                    case "optionsetvalue":
                        OptionSetValue optionValue = (OptionSetValue)value;
                        returnValue = optionValue.Name;
                        break;
                    case "primarynamelookup":
                        string lookupName = value == null ? "" : value.ToString();
                        returnValue = @"<a class=""sparkle-grid-link"" href=""#"" primaryNameLookup=""1"">" + lookupName + "</a>";
                        break;
                }
            }
            return returnValue;
        }
示例#25
0
 public static Column BindColumn(Column column, bool dateOnly)
 {
     column.Editor = CrmDateEditor;
     column.Formatter = FormatterDateOnly;
     return column;
 }
示例#26
0
 public static string FormatterDateAndTime(int row, int cell, object value, Column columnDef, object dataContext)
 {
     string dateFormat = GetDateFormat(columnDef);
     if (dateFormat!=null && OrganizationServiceProxy.UserSettings != null)
     {
         dateFormat = OrganizationServiceProxy.UserSettings.DateFormatString + " " + OrganizationServiceProxy.UserSettings.TimeFormatString;
     }
     DateTime dateValue = (DateTime)value;
     return DateTimeEx.FormatDateSpecific(dateValue, dateFormat);
 }
        public static Column BindReadOnlyColumn(Column column,string typeCodeAttribute)
        {
            XrmLookupEditorOptions currencyLookupOptions = new XrmLookupEditorOptions();
            currencyLookupOptions.typeCodeAttribute = typeCodeAttribute;
            column.Options = currencyLookupOptions;
            column.Formatter = XrmLookupEditor.Formatter;

            return column;
        }
示例#28
0
        public static string FormatterDateOnly(int row, int cell, object value, Column columnDef, object dataContext)
        {
            string dateFormat = GetDateFormat(columnDef);

            DateTime dateValue = (DateTime)value;
            return DateTimeEx.FormatDateSpecific(dateValue, dateFormat);
        }
示例#29
0
        public static string AvgTotalsFormatter(Dictionary<string, object> totals, Column columnDef)
        {
            Dictionary<string, object> avg = (Dictionary<string, object>)totals["avg"];

            float? val = (avg!=null) ? (float?)avg[columnDef.Field] : null;
            if (val != null)
            {
                return "total: " + ((Math.Round(val * 100) / 100));
            }
            return "";
            
        }
示例#30
0
 public static XrmDateBindingOptions GetDateBindingOptions(Column columnDef)
 {
     object options = columnDef.Options;
     XrmDateBindingOptions dateOptions = null;
     if (options != null && options.GetType() == typeof(string))
     {
         dateOptions = new XrmDateBindingOptions();
         dateOptions.OverrideUserDateFormat = (string)columnDef.Options;
         return dateOptions;
     }
     else if (options!=null)
     {
         dateOptions = (XrmDateBindingOptions)options;
     }
     else
     {
         dateOptions = new XrmDateBindingOptions();
     }
     return dateOptions;
 }