public static NsGrid UtworzGridView(GridView opisPola, bool isPostBack, Page page)
        {
            var radGrid = new NsGrid()
            {
                Widget = opisPola, ToolTip = opisPola.ToolTip
            };

            radGrid.AutoGenerateColumns          = false;
            radGrid.MasterTableView.DataKeyNames = new string[] { "Id" };
            UstawParametryGrida(opisPola, radGrid, isPostBack);
            UtworzKolumny(opisPola.Columns, radGrid, isPostBack, page);

            return(radGrid);
        }
        public static void UstawParametryGrida(GridView opisGrida, NsGrid radGrid, bool isPostBack)
        {
            radGrid.MasterTableView.CommandItemSettings.SaveChangesText        = "Zapisz zmiany";
            radGrid.MasterTableView.CommandItemSettings.CancelChangesText      = "Anuluj";
            radGrid.MasterTableView.CommandItemSettings.RefreshText            = "Odśwież";
            radGrid.MasterTableView.CommandItemSettings.ShowAddNewRecordButton = false;
            radGrid.ShowHeader = true;
            radGrid.Width      = Unit.Percentage(99);
            //radGrid.ClientSettings.AllowRowsDragDrop = opisPola.CzyDragDrop;
            radGrid.PagerStyle.Mode        = GridPagerMode.NextPrevAndNumeric;
            radGrid.ShowStatusBar          = true;
            radGrid.ShowFooter             = true;
            radGrid.AllowMultiRowSelection = true;
            radGrid.EnableLinqExpressions  = false;

            //Set options to enable Group-by
            radGrid.GroupingEnabled = false;
            radGrid.ShowGroupPanel  = false;
            radGrid.ClientSettings.AllowDragToGroup         = false;
            radGrid.ClientSettings.AllowColumnsReorder      = false;
            radGrid.ClientSettings.Selecting.AllowRowSelect = true;
            radGrid.MasterTableView.EnableColumnsViewState  = false;

            radGrid.AllowSorting         = opisGrida.AllowSorting;
            radGrid.AllowPaging          = opisGrida.AllowPaging;
            radGrid.PageSize             = opisGrida.PageSize;
            radGrid.PagerStyle.PageSizes = new int[] { 20, 50, 100, 300, 3000 };
            radGrid.MasterTableView.PagerStyle.PageSizes = radGrid.PagerStyle.PageSizes;
            radGrid.AllowCustomPaging = opisGrida.AllowPaging;
            if (opisGrida.GroupingEnabled)
            {
                radGrid.ShowGroupPanel     = true;
                radGrid.GroupingEnabled    = true;
                radGrid.GroupPanel.Visible = true;
                radGrid.ClientSettings.AllowDragToGroup = true;
                radGrid.GroupPanel.Text = "Przeciągnij kolumnę żeby grupować";
                radGrid.MasterTableView.ShowGroupFooter = true;
            }

            if (opisGrida.AggregateEnabled)
            {
                radGrid.ShowFooter = true;
                radGrid.MasterTableView.ShowFooter = true;
            }

            if (opisGrida.AllowEditing == true)
            {
                radGrid.AllowAutomaticUpdates = false;

                //radGrid.
                radGrid.MasterTableView.BatchEditingSettings.EditType         = GridBatchEditingType.Cell;
                radGrid.MasterTableView.BatchEditingSettings.OpenEditingEvent = GridBatchEditingEventType.DblClick;
                radGrid.MasterTableView.CommandItemDisplay     = GridCommandItemDisplay.TopAndBottom;
                radGrid.ClientSettings.AllowKeyboardNavigation = true;
                radGrid.MasterTableView.EditMode      = GridEditMode.Batch;
                radGrid.AllowAutomaticUpdates         = false;
                radGrid.EnableHeaderContextMenu       = true;
                radGrid.EnableHeaderContextFilterMenu = true;
            }

            if (opisGrida.AllowFilteringByColumn)
            {
                radGrid.AllowFilteringByColumn = true;
                radGrid.MasterTableView.AllowFilteringByColumn = true;
            }
        }