Ejemplo n.º 1
0
        protected virtual void SetMultipleSelection(GridViewRow row)
        {
            if (EnabledMultipleSelection && row.RowType == DataControlRowType.DataRow)
            {
                CheckBox cbSelect = (CheckBox)row.FindControl("cbSelect");

                if (cbSelect != null)
                {
                    // Set event on click on check box
                    var id = this.DataKeys[row.RowIndex].Value.ToString();
                    cbSelect.Checked = SelectedValues.Contains(id);

                    // check/uncheck checkbox on cell click
                    int    multColIndex = MultipleSelectionUseFlexibleColumn ? MultipleSelectionColumnIndex : row.Cells.Count - 1;
                    string script       = string.Format(
                        @"var cb = document.getElementById('{0}');
cb.checked = !cb.checked;
$(cb).parent().toggleClass('checked', cb.checked);", cbSelect.ClientID);
                    if (SelectCheckBoxOnRowClick)
                    {
                        DLGridView.SetScriptForCellOnRowClick(row, script, multColIndex);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            if (string.IsNullOrEmpty(Question))
            {
                throw new Exception("Property Question must be filled!");
            }

            String[] mess = { YesMessage, NoMessage };

            if (Mode == ModeType.Inline)
            {
                if (Label == null)
                {
                    throw new Exception("Property Label must be filled!");
                }
                grid = GetParentGrid(this);
                ConfirmScript(writer, Label, mess, true);
            }
            else
            {
                if (string.IsNullOrEmpty(DependsOnGrid))
                {
                    throw new Exception("Property DependsOnGrid must be filled!");
                }
                if (string.IsNullOrEmpty(BindLabelFromColumn))
                {
                    throw new Exception("Property BindLabelFromColumn must be filled!");
                }

                //if (string.IsNullOrEmpty(Label)) throw new Exception("Property Label must be filled!");
                grid = (DLGridView)(Page as DLPageTemplate).FindControlRecursive(Page, DependsOnGrid);
                if ((grid.SelectedDataKey != null) && ((grid.EnabledMultipleSelection == null && grid.SelectedValue != null) || (grid.EnabledMultipleSelection == true && grid.SelectedValues.Count > 0)))
                //if (grid.SelectedRow != null)
                {
                    if (grid.content != null)
                    {
                        var contentTable     = grid.content.ToTable();
                        var selectedRowIndex = grid.SelectedRow.DataItemIndex;
                        var columnIndex      = contentTable.Columns.IndexOf(BindLabelFromColumn);
                        var lab = contentTable.Rows[selectedRowIndex][columnIndex].ToString();

                        ConfirmScript(writer, lab, mess, true);
                    }
                }
                else
                {
                    writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none");
                }
            }

            base.AddAttributesToRender(writer);
        }
Ejemplo n.º 3
0
        private void AddItemsField(Control parent)
        {
            // Add grid view on page
            if (this.Items != null && this.Items.Count > 0)
            {
                if (_grid == null)
                {
                    _grid = new DLGridView();
                    _grid.AutoGenerateColumns      = false;
                    _grid.DataKeyNames             = new string[] { "Value" };
                    _grid.AllowPaging              = true;
                    _grid.PagerShowFirstAndLast    = true;
                    _grid.PagerShowNextAndPrevious = true;
                    _grid.PagerSettings.Position   = PagerPosition.TopAndBottom;
                    _grid.PageLinksToShow          = 9;
                    _grid.PageSize = 5;
                    _grid.EnabledMultipleSelection    = true;
                    _grid.MultipleSelectionUseLiteral = true;
                    _grid.ID             = "grid";
                    _grid.CssClass       = GridCssClass;
                    _grid.SelectedValues = this.SelectedValues;
                    _grid.DataBound     += new EventHandler(_grid_DataBound);
                    _grid.Columns.Add(new BoundField()
                    {
                        ShowHeader = false, HeaderText = string.Empty
                    });
                }

                if (!parent.Controls.Contains(_grid))
                {
                    parent.Controls.Add(_grid);
                }

                // Set data table to grid view.
                _grid.SetTableContent(GetDataTable().DefaultView);
                _grid.ContentBind();
            }

            if (Items == null || Items.Count == 0)
            {
                var messageControl = parent.FindControl("messageNoItems");
                if (messageControl == null)
                {
                    parent.Controls.Add(new Literal {
                        ID = "messageNoItems", Text = EmptyDataText
                    });
                }
            }
        }