예제 #1
0
 protected override void SetupFilterControls(TableCell cell)
 {
     try
     {
         base.SetupFilterControls(cell);
         this.ItemStyle.CssClass = "IndGridEditColumn";
         //Beacuse of a bug of Telerik we can not remove the controls, so we make them invisible
         foreach (Control c in cell.Controls)
         {
             c.Visible = false;
         }
         IndImageButton filterButton = new IndImageButton();
         filterButton.ID           = "btnApplyFilter";
         filterButton.ImageUrl     = "~/Images/buttons_filter.png";
         filterButton.ImageUrlOver = "~/Images/buttons_filter_over.png";
         filterButton.Click       += new System.Web.UI.ImageClickEventHandler(filterButton_Click);
         filterButton.ToolTip      = "Apply Filter";
         cell.Controls.Add(filterButton);
     }
     catch (IndException ex)
     {
         ControlHierarchyManager.ReportError(ex);
         return;
     }
     catch (Exception ex)
     {
         ControlHierarchyManager.ReportError(new IndException(ex));
         return;
     }
 }
예제 #2
0
        /// <summary>
        /// ItemCreated event handler of the generic grid
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GenericGrid_ItemCreated(object sender, GridItemEventArgs e)
        {
            if (!DesignMode)
            {
                if (e.Item is GridDataItem)
                {
                    if (_UserCanEdit)
                    {
                        //Add an edit button image to each element of the edit column
                        IndImageButton btnEdit = new IndImageButton();

                        btnEdit.ImageUrl     = "~/Images/buttons_editrow.png";
                        btnEdit.ImageUrlOver = "~/Images/buttons_editrow_over.png";
                        btnEdit.ID           = "btnEdit" + e.Item.ItemIndex;
                        btnEdit.Attributes.Add("ItemIndex", e.Item.ItemIndex.ToString());
                        btnEdit.ToolTip = "Edit";
                        string editControl = SessionManager.GetSessionValueRedirect((IndBasePage)this.Page, SessionStrings.EDIT_CONTROL).ToString();
                        btnEdit.OnClientClick = "return OpenEditWindow(this,'" + editControl + "',false, '" + ResolveUrl("~/Default.aspx?SessionExpired=1") + "');";
                        ((GridDataItem)e.Item)["EditColumn"].Controls.Add(btnEdit);
                    }
                    //Add a checkbox to each element of the delete column
                    CheckBox chkDelete = new CheckBox();
                    chkDelete.ID      = "chkBox";
                    chkDelete.Enabled = _UserCanDelete;
                    ((GridDataItem)e.Item)["DeleteColumn"].Controls.Add(chkDelete);
                }
            }
        }
예제 #3
0
        private void SetOnKeyPressFiltering(TableCell cell, TextBox txtFilter)
        {
            TableCell editCell = null;

            //If the parent of cell is null or it is not of GridFilteringItem type, return
            if (cell.Parent == null || !(cell.Parent is GridFilteringItem))
            {
                return;
            }
            //If the parent table of this GridFilteringItem does not contain a column named "EditColumn", return
            if (((GridFilteringItem)cell.Parent).OwnerTableView.Columns.FindByUniqueNameSafe("EditColumn") == null)
            {
                return;
            }

            //Get the cell in the header of the edit column (where the "apply filter" button is
            editCell = ((GridFilteringItem)cell.Parent)["EditColumn"];

            IndImageButton filterButton = (IndImageButton)editCell.Controls[editCell.Controls.Count - 1];

            if (txtFilter.Visible)
            {
                txtFilter.Attributes.Add("onkeydown", "doFilter('" + filterButton.ClientID + "', event)");
            }
            if (GetColumnDataType() == typeof(bool))
            {
                DropDownList filterDdl = (DropDownList)cell.Controls[cell.Controls.Count - 1];
                filterDdl.Attributes.Add("onkeydown", "doFilter('" + filterButton.ClientID + "', event)");
            }
        }
    protected void grdImportDetails_ItemCreated(object sender, GridItemEventArgs e)
    {
        try
        {
            if (e.Item is GridPagerItem)
            {
                Label      lblChangePageSize = (Label)e.Item.FindControl("ChangePageSizeLabel");
                TextBox    txtChangePageSize = (TextBox)e.Item.FindControl("ChangePageSizeTextBox");
                LinkButton lnkChangePageSize = (LinkButton)e.Item.FindControl("ChangePageSizeLinkButton");
                LinkButton lnkGoToPage       = (LinkButton)e.Item.FindControl("GoToPageLinkButton");
                TextBox    txtChangePage     = (TextBox)e.Item.FindControl("GoToPageTextBox");
                //OnKeyDown is used to catch the Enter key and to change the page; OnKeyPress is used for key validation.
                //The reason of using 2 events is to take control on GridPagerItem native events
                //and to manage both azerty and qwerty keyboards.
                txtChangePage.Attributes.Add("OnKeyDown", "ChangePageRadGrid('" + lnkGoToPage.ClientID + "', event)");
                txtChangePage.Attributes.Add("OnKeyPress", "return RestrictKeys(event,'1234567890','" + txtChangePage.ClientID + "')");

                if (lblChangePageSize != null)
                {
                    lblChangePageSize.Visible = false;
                }

                if (txtChangePageSize != null)
                {
                    txtChangePageSize.Visible = false;
                }

                if (lnkChangePageSize != null)
                {
                    lnkChangePageSize.Visible = false;
                }
            }
            else if (e.Item is GridCommandItem)
            {
                Inergy.Indev3.WebFramework.WebControls.IndImageButton btnDelete = (Inergy.Indev3.WebFramework.WebControls.IndImageButton)e.Item.FindControl("btnDelete");
                if (btnDelete != null && !UserCanDelete)
                {
                    btnDelete.ImageUrl = "~/Images/buttons_delete_disabled.png";
                }
            }
        }
        catch (IndException indExc)
        {
            ShowError(indExc);
        }
        catch (Exception exc)
        {
            ShowError(new IndException(exc));
        }
    }
예제 #5
0
        public IndCatGrid()
        {
            if (!DesignMode)
            {
                this.EnableViewState    = false;
                this.AllowPaging        = true;
                this.PagerStyle.Visible = false;
                this.AllowSorting       = true;
                this.MasterTableView.AllowNaturalSort = false;

                this.EnableAJAX             = false;
                this.AllowFilteringByColumn = true;

                this.AutoGenerateColumns = false;

                this.ItemCreated    += new GridItemEventHandler(GenericGrid_ItemCreated);
                this.NeedDataSource += new GridNeedDataSourceEventHandler(GenericGrid_NeedDataSource);
                this.ColumnCreating += new GridColumnCreatingEventHandler(IndCatGrid_ColumnCreating);

                this.DataSourcePersistenceMode = GridDataSourcePersistenceMode.NoPersistence;

                //Add the add and delete buttons
                if (_UserCanAdd)
                {
                    btnAdd              = new IndImageButton();
                    btnAdd.ID           = "AddButton";
                    btnAdd.ImageUrl     = "~/Images/buttons_new.png";
                    btnAdd.ImageUrlOver = "~/Images/buttons_new_over.png";
                    btnAdd.ToolTip      = "Add";
                }

                btnDelete               = new IndImageButton();
                btnDelete.ID            = "DeleteButton";
                btnDelete.ImageUrl      = "~/Images/buttons_delete.png";
                btnDelete.ImageUrlOver  = "~/Images/buttons_delete_over.png";
                btnDelete.OnClientClick = "if (CheckBoxesSelected()) {if(!confirm('Are you sure you want to delete the selected entries?'))return false;}else {alert('Select at least one entry');return false;}";
                btnDelete.Click        += new ImageClickEventHandler(DeleteButton_Click);
                btnDelete.ToolTip       = "Delete";
                btnDelete.Enabled       = _UserCanDelete;
            }

            ControlHierarchyManager = new ControlHierarchyManager(this);
        }
예제 #6
0
        protected override void SetupFilterControls(TableCell cell)
        {
            try
            {
                if (!this.Display)
                {
                    return;
                }
                base.SetupFilterControls(cell);
                this.Cell = cell;

                Image img = (Image)cell.Controls[1];
                cell.Controls.RemoveAt(1);
                IndImageButton btnImg = new IndImageButton();
                btnImg.ImageUrl = img.ImageUrl;
                btnImg.Height   = btnImg.Width = Unit.Pixel(0);

                TextBox txtFilter  = cell.Controls[0] as TextBox;
                string  onKeyPress = txtFilter.Attributes["onKeyPress"];
                onKeyPress = "return RestrictSpecialKeys(event,'%',\"" + txtFilter.ClientID + "\")" + ((onKeyPress == null) ? String.Empty : onKeyPress);

                txtFilter.Attributes["onKeyPress"] = onKeyPress;

                if (GetColumnDataType() == typeof(bool))
                {
                    if (txtFilter != null)
                    {
                        txtFilter.Visible = false;
                    }
                    AddBooleanFilter(cell);
                }
                if (GetColumnDataType() == typeof(DateTime))
                {
                    if (txtFilter != null)
                    {
                        txtFilter.Visible = false;
                    }
                    AddDateFilter(cell);
                }

                //Set the maxlength property of the filter controls
                SetFilterControlsMaxLength(cell, txtFilter);

                //Apply on key press filtering
                SetOnKeyPressFiltering(cell, txtFilter);

                cell.Controls.Add(btnImg);
                //Applies css class to this column, depending on its position in the grid
                ApplyColumnCSSClass();
            }
            catch (IndException ex)
            {
                ControlHierarchyManager.ReportError(ex);
                return;
            }
            catch (Exception ex)
            {
                ControlHierarchyManager.ReportError(new IndException(ex));
                return;
            }
        }