示例#1
0
 private void GenerateColumns()
 {
     Columns = new GridColumns();
     if (Data != null)
     {
         var    items = (IEnumerable)Data;
         object fitem = null;
         foreach (var item in items)
         {
             fitem = item;
             break;
         }
         string[] collist = fitem.GetType().GetProperties().Select(col => col.Name).ToArray();
         foreach (string col in collist)
         {
             Columns.Add(new GridColumn
             {
                 BindRow      = col,
                 DefaultValue = string.Empty,
                 Name         = col,
                 EnableSort   = false
             });
         }
     }
 }
示例#2
0
        public void Add_GridColumn()
        {
            Expression <Func <GridModel, String> > expression = (model) => model.Name;

            columns.Add(expression);

            GridColumn <GridModel, String> expected = new GridColumn <GridModel, String>(columns.Grid, expression);
            GridColumn <GridModel, String> actual   = columns.Single() as GridColumn <GridModel, String>;

            Assert.Equal(expected.Title.ToString(), actual.Title.ToString());
            Assert.Equal(expected.ProcessorType, actual.ProcessorType);
            Assert.Equal(expected.IsFilterable, actual.IsFilterable);
            Assert.Equal(expected.FilterName, actual.FilterName);
            Assert.Equal(expected.Expression, actual.Expression);
            Assert.Equal(expected.CssClasses, actual.CssClasses);
            Assert.Equal(expected.IsSortable, actual.IsSortable);
            Assert.Equal(expected.SortOrder, actual.SortOrder);
            Assert.Equal(expected.IsEncoded, actual.IsEncoded);
            Assert.Equal(expected.Format, actual.Format);
            Assert.Equal(expected.Name, actual.Name);
            Assert.Equal(expected.Grid, actual.Grid);
        }
示例#3
0
        public void Add_GridColumn()
        {
            IGridColumn <GridModel, Object> expected = new GridColumn <GridModel, Object>(columns.Grid, model => "");
            IGridColumn <GridModel, Object> actual   = columns.Add();

            Assert.Equal("", actual.Expression.Compile().Invoke(new GridModel()));
            Assert.Equal(expected.Filter.IsEnabled, actual.Filter.IsEnabled);
            Assert.Equal(expected.Title.ToString(), actual.Title.ToString());
            Assert.Equal(expected.Sort.IsEnabled, actual.Sort.IsEnabled);
            Assert.Equal(expected.ProcessorType, actual.ProcessorType);
            Assert.Equal(expected.Filter.Type, actual.Filter.Type);
            Assert.Equal(expected.Filter.Name, actual.Filter.Name);
            Assert.Equal(expected.CssClasses, actual.CssClasses);
            Assert.Equal(expected.Sort.Order, actual.Sort.Order);
            Assert.Equal(expected.IsEncoded, actual.IsEncoded);
            Assert.Equal(expected.Format, actual.Format);
            Assert.Equal(expected.Name, actual.Name);
            Assert.Equal(expected.Grid, actual.Grid);
        }
示例#4
0
        public void Add_EmptyGridColumn()
        {
            columns.Add();

            GridColumn <GridModel, Object> expected = new GridColumn <GridModel, Object>(columns.Grid, model => null);
            GridColumn <GridModel, Object> actual   = columns.Single() as GridColumn <GridModel, Object>;

            Assert.Equal(expected.Title.ToString(), actual.Title.ToString());
            Assert.Equal(expected.ProcessorType, actual.ProcessorType);
            Assert.Equal(expected.IsFilterable, actual.IsFilterable);
            Assert.Null(actual.Expression.Compile().Invoke(null));
            Assert.Equal(expected.FilterName, actual.FilterName);
            Assert.Equal(expected.CssClasses, actual.CssClasses);
            Assert.Equal(expected.IsSortable, actual.IsSortable);
            Assert.Equal(expected.SortOrder, actual.SortOrder);
            Assert.Equal(expected.IsEncoded, actual.IsEncoded);
            Assert.Equal(expected.Format, actual.Format);
            Assert.Equal(expected.Name, actual.Name);
            Assert.Equal(expected.Grid, actual.Grid);
        }