Esempio n. 1
0
        protected void gv1_CustomJSProperties(object sender, CustomJSPropertiesEventArgs e)
        {
            ASPxGridView gv_effect        = sender as ASPxGridView;
            Hashtable    selectedRowTable = new Hashtable();

            for (int i = 0; i < gv_effect.VisibleRowCount; i++)
            {
                DataRow dr = gv_effect.GetDataRow(i);
                if (!selectedRowTable.ContainsKey(dr["OBID"].ToString()))
                {
                    selectedRowTable.Add(dr["OBID"].ToString(), string.Format("{0} {1}", dr["TagNo"].ToString(), dr["Location"].ToString()));
                }
            }
            e.Properties["cpgetTokenname"] = selectedRowTable;
        }
    protected void grid_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
    {
        needToSelectAll = false;
        bool.TryParse(e.Parameters, out needToSelectAll);

        ASPxGridView gridView = (ASPxGridView)sender;

        int startIndex = gridView.PageIndex * gridView.SettingsPager.PageSize;
        int endIndex   = Math.Min(gridView.VisibleRowCount, startIndex + gridView.SettingsPager.PageSize);

        for (int i = startIndex; i < endIndex; i++)
        {
            if (needToSelectAll)
            {
                ASPxCheckBox cb  = (ASPxCheckBox)gridView.FindRowCellTemplateControl(i, (GridViewDataColumn)gridView.Columns["#"], "cbCheck");
                DataRow      row = gridView.GetDataRow(i);
                gridView.Selection.SetSelection(i, IsCheckBoxVisibleCriteria(row));
            }
            else
            {
                gridView.Selection.SetSelection(i, needToSelectAll);
            }
        }
    }
Esempio n. 3
0
    protected void gridEmployees_CustomCallback(object source, ASPxGridViewCustomCallbackEventArgs e)
    {
        string       param = e.Parameters.ToString();
        ASPxGridView gdv   = source as ASPxGridView;

        gdv.JSProperties[JSPROPERTY_CALLBACK_TYPE] = param;
        switch (param)
        {
        case GRID_INVERSE:
            if (gdv.VisibleRowCount > 0)
            {
                for (int i = 0; i < gdv.VisibleRowCount; i++)
                {
                    gdv.Selection.SetSelection(i, !gdv.Selection.IsRowSelected(i));
                }
            }
            break;

        case GRID_BINDING:
            gdv.DataBind();
            break;

        case GRID_SELECT_BY_VALUE:
            if (gdv.VisibleRowCount > 0 && bteEmployees.Text.Length > 0)
            {
                DataRow dr;
                if (multiSelection)
                {
                    string[] employeesNos = bteEmployees.Text.Split(',');
                    if (employeesNos.Length > 0)
                    {
                        bool          isContain;
                        StringBuilder accounts     = new StringBuilder();
                        StringBuilder selectedText = new StringBuilder();
                        StringBuilder employeeNos  = new StringBuilder();
                        for (int i = 0; i < gdv.VisibleRowCount; i++)
                        {
                            dr        = gdv.GetDataRow(i);
                            isContain = employeesNos.Contains <string>(dr[FIELDNAME_EMPLOYEENO].ToString());
                            gdv.Selection.SetSelection(i, isContain);
                            if (isContain)
                            {
                                accounts.AppendFormat(",{0}", dr[FIELDNAME_ACCOUNTID]);
                                employeeNos.AppendFormat(",{0}", dr[FIELDNAME_EMPLOYEENO]);
                                selectedText.AppendFormat("<br>{0} - {1} - {2}", dr[FIELDNAME_DIVISIONCODE],
                                                          dr[FIELDNAME_EMPLOYEENO], dr[FIELDNAME_EMPLOYEENAME]);
                            }
                        }
                        if (accounts.Length > 0)
                        {
                            //gdv.JSProperties[JSPROPERTY_LBL_SELECTED] = TEXT_EMPLOYEES;
                            gdv.JSProperties[JSPROPERTY_TEXT_POPUP_SELECTED] = selectedText.ToString();
                            gdv.JSProperties[JSPROPERTY_SELECTED_ACCOUNTID]  = accounts.ToString().Substring(1);
                            gdv.JSProperties[JSPROPERTY_SELECTED_EMPLOYEENO] = employeeNos.ToString().Substring(1);
                            return;
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < gdv.VisibleRowCount; i++)
                    {
                        dr = gdv.GetDataRow(i);
                        gdv.Selection.SetSelection(i, bteEmployees.Text == dr[FIELDNAME_EMPLOYEENO].ToString());
                        if (gdv.Selection.IsRowSelected(i))
                        {
                            gdv.JSProperties[JSPROPERTY_LBL_SELECTED]        = dr[FIELDNAME_EMPLOYEENAME];
                            gdv.JSProperties[JSPROPERTY_SELECTED_ACCOUNTID]  = dr[FIELDNAME_ACCOUNTID];
                            gdv.JSProperties[JSPROPERTY_SELECTED_EMPLOYEENO] = dr[FIELDNAME_EMPLOYEENO];
                            return;
                        }
                    }
                }
            }
            gdv.Selection.UnselectAll();
            gdv.JSProperties[JSPROPERTY_LBL_SELECTED]        = "";
            gdv.JSProperties[JSPROPERTY_TEXT_POPUP_SELECTED] = "";
            gdv.JSProperties[JSPROPERTY_SELECTED_ACCOUNTID]  = "";
            gdv.JSProperties[JSPROPERTY_SELECTED_EMPLOYEENO] = "";

            break;

        case GRID_SELECTED:
            if (gdv.VisibleRowCount > 0)
            {
                if (multiSelection)
                {
                    StringBuilder accounts     = new StringBuilder();
                    StringBuilder selectedText = new StringBuilder();
                    StringBuilder employeeNos  = new StringBuilder();
                    List <object> selectedList = gdv.GetSelectedFieldValues(FIELDNAME_ACCOUNTID, FIELDNAME_DIVISIONCODE
                                                                            , FIELDNAME_EMPLOYEENO, FIELDNAME_EMPLOYEENAME);
                    foreach (object obj in selectedList)
                    {
                        object[] data = obj as object[];
                        accounts.AppendFormat(",{0}", data[0]);
                        employeeNos.AppendFormat(",{0}", data[2]);
                        selectedText.AppendFormat("<br>{0} - {1} - {2}", data[1], data[2], data[3]);
                    }
                    if (accounts.Length > 0)
                    {
                        //gdv.JSProperties[JSPROPERTY_LBL_SELECTED] = TEXT_EMPLOYEES;
                        gdv.JSProperties[JSPROPERTY_TEXT_POPUP_SELECTED] = selectedText.ToString();
                        gdv.JSProperties[JSPROPERTY_SELECTED_ACCOUNTID]  = accounts.ToString().Substring(1);
                        gdv.JSProperties[JSPROPERTY_SELECTED_EMPLOYEENO] = employeeNos.ToString().Substring(1);
                    }
                    else
                    {
                        //gdv.JSProperties[JSPROPERTY_LBL_SELECTED] = "";
                        gdv.JSProperties[JSPROPERTY_TEXT_POPUP_SELECTED] = "";
                        gdv.JSProperties[JSPROPERTY_SELECTED_ACCOUNTID]  = "";
                        gdv.JSProperties[JSPROPERTY_SELECTED_EMPLOYEENO] = "";
                    }
                }
                else
                {
                    int      index = Int32.Parse(hddEmployeesSelected[HDDKEY_SELECTED_INDEX].ToString());
                    object[] data  = gdv.GetRowValues(index, FIELDNAME_ACCOUNTID, FIELDNAME_EMPLOYEENO
                                                      , FIELDNAME_EMPLOYEENAME) as object[];
                    gdv.JSProperties[JSPROPERTY_SELECTED_ACCOUNTID]  = data[0];
                    gdv.JSProperties[JSPROPERTY_SELECTED_EMPLOYEENO] = data[1];
                    gdv.JSProperties[JSPROPERTY_LBL_SELECTED]        = data[2];
                    gdv.Selection.UnselectAll();
                    gdv.Selection.SetSelection(index, true);
                }
            }
            break;

        case GRID_UNDO_SELECTED:
            gdv.Selection.UnselectAll();
            if (!hddEmployeesSelected.Contains(HDDKEY_EMPLOYEES_SELECTED) ||
                String.IsNullOrEmpty(hddEmployeesSelected[HDDKEY_EMPLOYEES_SELECTED].ToString()))
            {
                return;
            }
            string[] keys = hddEmployeesSelected[HDDKEY_EMPLOYEES_SELECTED].ToString().Split(',');
            foreach (string key in keys)
            {
                gdv.Selection.SetSelectionByKey(Int32.Parse(key), true);
            }
            break;

        default: break;
        }
    }