Пример #1
0
 /// <summary>
 /// Specifies function that should return plain text value string to be inserted to resulting table
 /// </summary>
 /// <param name="conf">Column</param>
 /// <param name="function">JS function text. Like "function(v){ ... }"</param>
 /// <returns>Fluent</returns>
 public static ColumnUsage <TSourceData, TTableData, TTableColumn> TemplateFunction <TSourceData, TTableData, TTableColumn>
     (this ColumnUsage <TSourceData, TTableData, TTableColumn> conf, string function) where TTableData : new()
 {
     if (!string.IsNullOrEmpty(conf.ColumnConfiguration.CellRenderingTemplateId))
     {
         throw new Exception("Column has already specified TemplateId. TemplateFunction is redundant. Please remove it.");
     }
     conf.ColumnConfiguration.CellRenderingValueFunction = new JRaw(function);
     return(conf);
 }
Пример #2
0
 /// <summary>
 /// Subscribes event handler of DOM event occured on each cell of this column (without headers)
 /// Please use this function to subscribe cell events instead of template bindings or onclick to
 /// improve event handling time and reduce RAM usage. This method actually makes table to subscribe cell
 /// event via events delegator
 /// </summary>
 /// <param name="conf">Table configurator</param>
 /// <param name="eventId">DOM event ID. You can use clas DomEvent here</param>
 /// <param name="handler">Handler function that supplies data object as first parameter and row element as second one (inline function or function name)</param>
 /// <param name="selctor">(Optional) Selector of element triggering event (relative to cell)</param>
 /// <returns></returns>
 public static ColumnUsage <TSourceData, TTableData, TColumn> SubscribeCellEvent <TSourceData, TTableData, TColumn>
     (this ColumnUsage <TSourceData, TTableData, TColumn> conf, string eventId, string handler, string selctor = null) where TTableData : new()
 {
     conf.TableConfigurator.TableConfiguration.Subscriptions.Add(new ConfiguredSubscriptionInfo()
     {
         IsRowSubscription = false,
         ColumnName        = conf.ColumnProperty.Name,
         DomEvent          = eventId,
         Handler           = new JRaw(handler),
         Selector          = selctor
     });
     return(conf);
 }
Пример #3
0
        /// <summary>
        /// Retrieves column configurator
        /// </summary>
        /// <typeparam name="TColType">Column type</typeparam>
        /// <param name="column">Column</param>
        /// <returns>Corresponding column configurator</returns>
        public ColumnUsage <TSourceData, TTableData, TColType> Column <TColType>(Expression <Func <TTableData, TColType> > column)
        {
            var targetProperty = LambdaHelpers.ParsePropertyLambda(column);

            targetProperty = _tableColumnsDictionary[targetProperty.Name];
            if (_configurators.ContainsKey(targetProperty))
            {
                return((ColumnUsage <TSourceData, TTableData, TColType>)_configurators[targetProperty]);
            }
            ColumnUsage <TSourceData, TTableData, TColType> usage = new ColumnUsage <TSourceData, TTableData, TColType>(this, column, GetColumnConfiguration(targetProperty));

            _configurators[targetProperty] = usage;
            return(usage);
        }
Пример #4
0
 /// <summary>
 /// Specifies JS function for client-side cell value evaluation for particular mentioned column
 /// </summary>
 /// <typeparam name="TSourceData"></typeparam>
 /// <typeparam name="TTableData"></typeparam>
 /// <typeparam name="TTableColumn"></typeparam>
 /// <param name="conf">Column configurator</param>
 /// <param name="clientValueFunction">Client valuation function. Can be reference to existing JS function or inline one. Function signature is (dataObject:any) => any</param>
 /// <returns></returns>
 public static ColumnUsage <TSourceData, TTableData, TTableColumn> ClientExpression <TSourceData, TTableData, TTableColumn>(this ColumnUsage <TSourceData, TTableData, TTableColumn> conf, string clientValueFunction) where TTableData : new()
 {
     clientValueFunction = Template.CompileExpression(clientValueFunction, "v", null);
     conf.ColumnConfiguration.ClientValueFunction = string.IsNullOrEmpty(clientValueFunction) ? null : new JRaw(clientValueFunction);
     return(conf);
 }
Пример #5
0
 /// <summary>
 /// Specifies JS function for client-side cell value evaluation for particular mentioned column
 /// </summary>
 /// <typeparam name="TSourceData"></typeparam>
 /// <typeparam name="TTableData"></typeparam>
 /// <typeparam name="TTableColumn"></typeparam>
 /// <param name="conf">Column configurator</param>
 /// <param name="clientValueFunction">Client valuation function. Can be reference to existing JS function or inline one. Function signature is (dataObject:any) => any</param>
 /// <returns></returns>
 public static ColumnUsage <TSourceData, TTableData, TTableColumn> ClientFunction <TSourceData, TTableData, TTableColumn>(this ColumnUsage <TSourceData, TTableData, TTableColumn> conf, string clientValueFunction) where TTableData : new()
 {
     conf.ColumnConfiguration.ClientValueFunction = string.IsNullOrEmpty(clientValueFunction) ? null : new JRaw(clientValueFunction);
     return(conf);
 }
Пример #6
0
 /// <summary>
 /// Instructs Lattice do not to create column for this property.
 /// Specified column will be passed to client but will not be displayed in table.
 /// It is useful to optimize table rendering by excluding data that not required as separate column
 /// but still used for Value/HTML function
 /// </summary>
 /// <param name="conf">Column configuration</param>
 /// <param name="isDataOnly">Enable or disable .DataOnly</param>
 public static void DataOnly <TSourceData, TTableData, TTableColumn>
     (this ColumnUsage <TSourceData, TTableData, TTableColumn> conf, bool isDataOnly = true) where TTableData : new()
 {
     conf.ColumnConfiguration.IsDataOnly = isDataOnly;
 }
Пример #7
0
 /// <summary>
 /// Specifies handlebarsjs template id to be used for rendering of this column.
 /// Specified template will be compiled at the beginnig of processing.
 /// JSON-ed TTableData is used as tempalte model. So you can use all columns and not only current
 /// column value
 /// </summary>
 /// <param name="conf">Column</param>
 /// <param name="templateId">Template id (without "#" or other selectors)</param>
 /// <returns>Fluent</returns>
 public static ColumnUsage <TSourceData, TTableData, TTableColumn> TemplateId <TSourceData, TTableData, TTableColumn>(this ColumnUsage <TSourceData, TTableData, TTableColumn> conf, string templateId) where TTableData : new()
 {
     if ((conf.ColumnConfiguration.CellRenderingValueFunction != null))
     {
         throw new Exception("Column has already specified value function. TemplateId is redundant. Please remove it.");
     }
     conf.ColumnConfiguration.CellRenderingTemplateId = templateId;
     return(conf);
 }
Пример #8
0
 /// <summary>
 /// Sets up column title
 /// </summary>
 /// <param name="conf">Column</param>
 /// <param name="title">Title text</param>
 /// <returns>Fluent</returns>
 public static ColumnUsage <TSourceData, TTableData, TTableColumn> Title <TSourceData, TTableData, TTableColumn>(this ColumnUsage <TSourceData, TTableData, TTableColumn> conf, string title) where TTableData : new()
 {
     conf.ColumnConfiguration.Title = title;
     return(conf);
 }
Пример #9
0
 /// <summary>
 /// Registers column mapping to be used in case of disabled .ProjectDataWith.
 /// .MappedFrom functions are being called simultaneously when evaluating resulting data set to be sent to client
 /// </summary>
 /// <param name="conf">Table configurator</param>
 /// <param name="converter">Mapping function</param>
 /// <returns></returns>
 public static ColumnUsage <TSourceData, TTableData, TTableColumn> MappedFrom <TSourceData, TTableData, TTableColumn>(this ColumnUsage <TSourceData, TTableData, TTableColumn> conf, Func <TSourceData, TTableColumn> converter) where TTableData : new()
 {
     conf.Configurator.RegisterMapping(conf.ColumnProperty, converter);
     return(conf);
 }