Exemplo n.º 1
0
    /// <summary>
    /// According to the ckeck state of the master checkbox selects or deselects the items down in the hierarchy
    /// </summary>
    /// <param name="tableView"></param>
    /// <param name="shouldCheck"></param>
    protected void CheckItemsInTableView(GridTableView tableView, bool shouldCheck)
    {
        int currentPageSize  = tableView.PageSize;
        int currentPageIndex = tableView.CurrentPageIndex;

        //Resizing the table view in order to increase the performance
        tableView.PageSize = int.MaxValue;
        tableView.Rebind();
        foreach (GridDataItem detailItem in tableView.Items)
        {
            detailItem.Selected = shouldCheck;
            (detailItem[CheckBoxTemplateColumnUniqueName].FindControl(CheckBoxId) as CheckBox).Checked = shouldCheck;
            GridTableView ownerTableView = detailItem.OwnerTableView;
            //Generates a unique identifier for the data item. This is done in order to distinguish every data item in the grid
            string dataKeyValue = GenerateUniqueIdentifier(detailItem);
            //Select or deselect the items in the current TableView
            this.SetCollectionValue(TableViews[ownerTableView.Name], dataKeyValue, shouldCheck);

            detailItem.Expanded = true;
            //If there is next level of hierarchy exist select or deselectes the items in it
            if (detailItem.ChildItem != null)
            {
                CheckItemsInTableView(detailItem.ChildItem.NestedTableViews[0], shouldCheck);
            }
        }
        tableView.PageSize         = currentPageSize;
        tableView.CurrentPageIndex = currentPageIndex;
        tableView.Rebind();
    }
Exemplo n.º 2
0
    protected void RadGrid1_SortCommand(object sender, Telerik.Web.UI.GridSortCommandEventArgs e)
    {
        GridTableView tableView = e.Item.OwnerTableView;

        e.Canceled = true;
        GridSortExpression expression = new GridSortExpression();

        expression.FieldName = "Customer";
        if (tableView.SortExpressions.Count == 0 || tableView.SortExpressions[0].FieldName != "Customer")
        {
            expression.SortOrder = GridSortOrder.Descending;
        }
        else if (tableView.SortExpressions[0].SortOrder == GridSortOrder.Descending)
        {
            expression.SortOrder = GridSortOrder.Ascending;
        }
        else if (tableView.SortExpressions[0].SortOrder == GridSortOrder.Ascending)
        {
            expression.SortOrder = GridSortOrder.None;
        }
        tableView.SortExpressions.AddSortExpression(expression);
        tableView.Rebind();

        LoadDataForRadGrid1();
        RadGrid1.DataBind();
    }
Exemplo n.º 3
0
    /// <summary>
    /// Checking if all the items in the GridTableView are checked in order to determine whether to check the master item
    /// </summary>
    /// <param name="nestedTableView"></param>
    /// <returns></returns>
    protected bool ShouldCheckMasterItem(GridTableView nestedTableView)
    {
        bool isChecked        = true;
        int  currentPageSize  = nestedTableView.PageSize;
        int  currentPageIndex = nestedTableView.CurrentPageIndex;

        //Resizing the table view in order to increase the performance
        nestedTableView.PageSize = int.MaxValue;
        nestedTableView.Rebind();
        foreach (GridDataItem detailItem in nestedTableView.Items)
        {
            string currentDataItem = GenerateUniqueIdentifier(detailItem);
            if (!TableViews[nestedTableView.Name].Contains(currentDataItem))
            {
                isChecked = false;
                break;
            }
        }
        nestedTableView.PageSize         = currentPageSize;
        nestedTableView.CurrentPageIndex = currentPageIndex;
        nestedTableView.Rebind();
        return(isChecked);
    }
Exemplo n.º 4
0
 /// <summary>
 /// Checking if all the items in the GridTableView are checked in order to determine whether to check the master item
 /// </summary>
 /// <param name="nestedTableView"></param>
 /// <returns></returns>
 protected bool ShouldCheckMasterItem(GridTableView nestedTableView)
 {
     bool isChecked = true;
     int currentPageSize = nestedTableView.PageSize;
     int currentPageIndex = nestedTableView.CurrentPageIndex;
     //Resizing the table view in order to increase the performance
     nestedTableView.PageSize = int.MaxValue;
     nestedTableView.Rebind();
     foreach (GridDataItem detailItem in nestedTableView.Items)
     {
         string currentDataItem = GenerateUniqueIdentifier(detailItem);
         if (!TableViews[nestedTableView.Name].Contains(currentDataItem))
         {
             isChecked = false;
             break;
         }
     }
     nestedTableView.PageSize = currentPageSize;
     nestedTableView.CurrentPageIndex = currentPageIndex;
     nestedTableView.Rebind();
     return isChecked;
 }
Exemplo n.º 5
0
    /// <summary>
    /// According to the ckeck state of the master checkbox selects or deselects the items down in the hierarchy
    /// </summary>
    /// <param name="tableView"></param>
    /// <param name="shouldCheck"></param>
    protected void CheckItemsInTableView(GridTableView tableView, bool shouldCheck)
    {
        int currentPageSize = tableView.PageSize;
        int currentPageIndex = tableView.CurrentPageIndex;
        //Resizing the table view in order to increase the performance
        tableView.PageSize = int.MaxValue;
        tableView.Rebind();
        foreach (GridDataItem detailItem in tableView.Items)
        {
            detailItem.Selected = shouldCheck;
            (detailItem[CheckBoxTemplateColumnUniqueName].FindControl(CheckBoxId) as CheckBox).Checked = shouldCheck;
            GridTableView ownerTableView = detailItem.OwnerTableView;
            //Generates a unique identifier for the data item. This is done in order to distinguish every data item in the grid
            string dataKeyValue = GenerateUniqueIdentifier(detailItem);
            //Select or deselect the items in the current TableView
            this.SetCollectionValue(TableViews[ownerTableView.Name], dataKeyValue, shouldCheck);

            detailItem.Expanded = true;
            //If there is next level of hierarchy exist select or deselectes the items in it
            if (detailItem.ChildItem != null)
            {
                CheckItemsInTableView(detailItem.ChildItem.NestedTableViews[0], shouldCheck);
            }
        }
        tableView.PageSize = currentPageSize;
        tableView.CurrentPageIndex = currentPageIndex;
        tableView.Rebind();
    }