Exemplo n.º 1
0
        public Grid DataBindXrmGrid(DataViewBase dataView, List <Column> columns, string gridId, string pagerId, bool editable, bool allowAddNewRow)
        {
            // Always add an empty column on the end for reszing purposes
            ArrayEx.Add(columns, new Column());

            GridOptions gridOptions = new GridOptions();

            gridOptions.EnableCellNavigation = true;
            gridOptions.AutoEdit             = editable;
            gridOptions.Editable             = editable;
            gridOptions.EnableAddRow         = allowAddNewRow;

            // Set non-variable options
            gridOptions.RowHeight           = 20;
            gridOptions.HeaderRowHeight     = 25;
            gridOptions.ForceFitColumns     = true;
            gridOptions.EnableColumnReorder = false;

            CheckboxSelectColumnOptions checkboxOptions = new CheckboxSelectColumnOptions();

            checkboxOptions.cssClass = "sparkle-checkbox-column";

            // Add check box column
            CheckboxSelectColumn checkBoxSelector = new CheckboxSelectColumn(checkboxOptions);
            Column checkBoxColumn = checkBoxSelector.GetColumnDefinition();

            columns.Insert(0, checkBoxColumn);


            Grid grid = new Grid("#" + gridId, dataView, columns, gridOptions);

            grid.RegisterPlugin(checkBoxSelector);
            this.DataBindSelectionModel(grid, dataView);
            if (!string.IsNullOrEmpty(pagerId))
            {
                CrmPagerControl pager = new CrmPagerControl(dataView, grid, jQuery.Select("#" + pagerId));
            }
            DataBindEvents(grid, dataView, gridId);
            AddValidation(grid, dataView);
            AddRefreshButton(gridId, dataView);

            // Add resize event
            jQuery.Window.Resize(delegate(jQueryEvent e){
                // Set each column to be non resizable while we do the resize
                FreezeColumns(grid, true);
                grid.ResizeCanvas();
                // Restore the resizing
                FreezeColumns(grid, false);
            });

            dataView.OnDataLoaded.Subscribe(delegate(EventData e, object o)
            {
                FreezeColumns(grid, false);
            });
            return(grid);
        }
Exemplo n.º 2
0
        /// <summary>
        /// DataBinds a DataView that inherits from DataViewBase
        /// 
        /// </summary>
        /// <param name="dataView"></param>
        /// <param name="columns"></param>
        /// <param name="gridId"></param>
        /// <param name="pagerId"></param>
        /// <param name="editable"></param>
        /// <param name="allowAddNewRow"></param>
        /// <returns></returns>
        public Grid DataBindXrmGrid(DataViewBase dataView, List<Column> columns, string gridId, string pagerId,bool editable, bool allowAddNewRow )
        {
            // Always add an empty column on the end for reszing purposes
            ArrayEx.Add(columns, new Column());

            GridOptions gridOptions = new GridOptions();
            gridOptions.EnableCellNavigation = true;
            gridOptions.AutoEdit = editable;
            gridOptions.Editable = editable;
            gridOptions.EnableAddRow = allowAddNewRow;

            // Set non-variable options
            gridOptions.RowHeight = PageEx.MajorVersion==2013 ? 30 : 20;
            gridOptions.HeaderRowHeight = 25;
            //gridOptions.ForceFitColumns = true;
            gridOptions.EnableColumnReorder = false;

            CheckboxSelectColumnOptions checkboxOptions = new CheckboxSelectColumnOptions();
            checkboxOptions.cssClass = "sparkle-checkbox-column";

            // Add check box column
            CheckboxSelectColumn checkBoxSelector = new CheckboxSelectColumn(checkboxOptions);
            Column checkBoxColumn = checkBoxSelector.GetColumnDefinition();
            columns.Insert(0, checkBoxColumn);

            Grid grid = new Grid("#" + gridId, dataView, columns, gridOptions);

            grid.RegisterPlugin(checkBoxSelector);
            this.DataBindSelectionModel(grid, dataView);
            if (!string.IsNullOrEmpty(pagerId))
            {
                CrmPagerControl pager = new CrmPagerControl(dataView, grid, jQuery.Select("#" + pagerId));
            }
            DataBindEvents(grid, dataView, gridId);
            AddValidation(grid, dataView);
            AddRefreshButton(gridId, dataView);

            // Add resize event
            jQuery.Window.Resize(delegate(jQueryEvent e){
                // Set each column to be non resizable while we do the resize
                FreezeColumns(grid, true);
                grid.ResizeCanvas();
                // Restore the resizing
                FreezeColumns(grid, false);
            });

            dataView.OnDataLoaded.Subscribe(delegate(EventData e, object o)
            {
                FreezeColumns(grid,false);
            });
            _grid = grid;
            return grid;
        }