Problem with Auto genertaed Check box Group

  1. #1

    Problem with Auto genertaed Check box Group

    Please I have problem with auto generated Check Box group, The problem is:

    I generated check box group depending on database table, and I can show it in panel correctly without any problem,
    when i check the check boxes the check boxes value save to database correctly without any problem,But the problem appear when | want to
    retrieve the check box that checked in insert time, So when I press updating button first time bring the check boxes but without show me the check boxes was checked but in the second press it's show me the the same check boxes with checked boxes

    so the problem in brief i want to press the updating button two time to see the checked boxes

    Thank you in advance
    Last edited by Egale; May 05, 2011 at 5:27 AM.
  2. #2
    Hi,

    Please make a smaller code sample which demonstrates how to reproduce the issue, and please wrap all code samples in [CODE] tags.

    The following posts can help provide more information, see

    http://forums.ext.net/showthread.php...ation-Required
    http://forums.ext.net/showthread.php...ing-New-Topics
    Geoffrey McGill
    Founder
  3. #3

    Ayto genertaed Check box Group

    My code is consist of the flowing parts: I think my problem is c# code i want to write something in the LoadGrid function , The CommandHandler is a function fire from update command column in gried panel.

    <%--Ext.net code --%>
    <%--this for create panel Accordion and put inside it 2 panel that contain the grout boxes --%>
    <ext:Panel IDMode="Static" ID="panAccordion" runat="server" Title="مراسل صادر وارد"
                        AutoHeight="true" Height="400" BodyBorder="false" Icon="ApplicationTileVertical"
                        Layout="Accordion" Hidden="true" AutoShow="True" AutoWidth="True">
                        <LayoutConfig>
                            <ext:AccordionLayoutConfig Animate="true" />
                        </LayoutConfig>
                        <Items>
                            <ext:Panel IDMode="Static" ID="Paout" runat="server" Title="مراسل صادر" Collapsed="true"
                                AutoHeight="true">
                                <Items>
                                    <ext:CheckboxGroup IDMode="Static" ID="cbgout" runat="server" ColumnsNumber="1" Hidden="true">
                                        <Items>
                                            <ext:Checkbox ID="cboutdef" runat="server" BoxLabel="lbcbout" Checked="true" />
                                        </Items>
                                    </ext:CheckboxGroup>
                                </Items>
                            </ext:Panel>
                            <ext:Panel ID="pain" runat="server" Title="مراسل وارد" Collapsed="true" AutoHeight="true">
                                <Items>
                                    <ext:CheckboxGroup IDMode="Static" ID="cbgin" runat="server" ColumnsNumber="1" Hidden="true">
                                        <Items>
                                            <ext:Checkbox ID="cbindef" runat="server" BoxLabel="lbcbin" Checked="true" />
                                        </Items>
                                    </ext:CheckboxGroup>
                                </Items>
                            </ext:Panel>
    //c# code to retrieve data
    //--------------------------
    [DirectMethod]
        public string CommandHandler(string command, int EmpID)
        {
    
            try
            {
                if (command == "Delete")
                {
                    Employees mc = new Employees();
                    mc = EmployeesDB.GetItem(EmpID);
                    // mc.MailCategory_ID = CategID;
                    mc.Employee_IsDeleted = true;
                    int x = EmployeesDB.Save(mc);
    
                    if (x > 0)
                    {
                        LoadGrid();
                        return "تمت عملية الحذف بنجاح";
    
                    }
                    else
                    {
                        return "يرجى المحاولة لاحقاً";
                    }
                }
                else if (command == "Edit")
                {
    
                    string ID = (string)hidevalu.Value;
                    int tempx = Convert.ToInt32(ID);
                    Employees emp = new Employees();
                    emp = EmployeesDB.GetItem(tempx);
                    Hierarchy hier = new Hierarchy();
    
                    txtEMPNm.Text = emp.Employee_Name;
                    txtLogin.Text = emp.Employee_UserName;
                   // txtpass.Text = emp.Employee_Password;
                    txtMail.Text = emp.Employee_EmailAdress;
                    ddlPositin.SetValue(emp.Employee_Position);
                    cbMainEmp.Checked = Convert.ToBoolean(emp.Employee_IsFirstReciever);
                    cbCtsEmp.Checked = Convert.ToBoolean(emp.Employee_IsCTSEmployee);
                    int hrnodId = Convert.ToInt32(emp.Hierarchy_ID);
                    hier = HierarchyDB.GetItem(hrnodId);
                    txtMang.Text = hier.Hierarchy_Name.ToString();
                    ///////////////////
                    hrnodId = Convert.ToInt32(emp.Hierarchy_SupervisorAtHierarchy_ID);
                    if (hrnodId != -1)
                    {
                        cbIS_supervis.Checked = true;
                        hier = HierarchyDB.GetItem(hrnodId);
                        txtSupervisior.Text = hier.Hierarchy_Name.ToString();
                    }
                    else {
                        cbIS_supervis.Checked = false;
                        txtSupervisior.Visible = false;
                    }
                    //////////////////
                    ddlRights.SetValue(emp.Group_ID);
    
                    //////////empCatalogprevaleg/////////
                    if (cbCtsEmp.Checked)
                    {
                        List<EmployeesCatigoriesPreveleges> empcp = EmployeesCatigoriesPrevelegesDB.GetList();
                        var empcplist = from empcatalogP in empcp
                                        where empcatalogP.Employee_ID == tempx //&& o.Hierarchy_IsDeleted == false 
                                        select empcatalogP;
                        EmployeesCatigoriesPreveleges emcatprev = empcplist.ElementAt(0);
    
                        cbResIn.Checked = emcatprev.EmployeeCatigoriesPrevelege_HaveImportPrevelege.Value;
    
                        cbRespOut.Checked = emcatprev.EmployeeCatigoriesPrevelege_HaveExportPrevelege.Value;
                        cbResIn.RemoveListener("Check", "GetByCatigory");
                        cbRespOut.RemoveListener("Check", "GetByCatigory");
                        if (cbRespOut.Checked)
                        {
                            Paout.Enabled = true;
                            string ExpPriv = emcatprev.EmployeeCatigoriesPrevelege_ExportCatigoriesPrevelegs;
                            string[] elem = ExpPriv.Split(',');
                            Paout.ClearContent();
                            cbgout.Hidden = false;
                            panAccordion.Hidden = false;
                            Paout.Hidden = false;
                            panAccordion.Show();
                            //Paout.Expand();
                            cbgout.Items.RemoveAt(0);
                            LoadGrid(0, elem);
                            cbRespOut.AddListener("Check", "GetByCatigory");
                        }
                        if (cbResIn.Checked)
                        {
                            pain.Enabled = true;
                            string ExpPriv = emcatprev.EmployeeCatigoriesPrevelege_ImportCatigoriesPrevelegs;
                            string[] elem1 = ExpPriv.Split(',');
                            cbgin.Hidden = false;
                            panAccordion.Hidden = false;
                            pain.Hidden = false;
                            // pain.Expand();
                            pain.ClearContent();
                            cbgin.Items.RemoveAt(0);
                            LoadGrid(1, elem1);
                            cbResIn.AddListener("Check", "GetByCatigory");
                        }
                        //if (cbRespOut.Checked)
                        //{
                        //    loadgrid(0, elem);
                        //}
                        //if (cbResIn.Checked)
                        //{
                        //    loadgrid(1, elem);
                        //}
                        return "ok";
    
                    }
    
                }
    
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
            return "Unkown";
        }
    //------------------------------------------------------------------
     private void LoadGrid(int value, string[] arr)
        {
            MailsCategories mailCat = new MailsCategories();
            mailCat.Hierarchy_CategoryType = value;
            List<MailsCategories> ms = MailsCategoriesDB.GetList(mailCat);
           
            ////////////////////////// ////////////////////////////////
            int i = 0;
    
            if (ms.Count() > 0)
            {
                //cbgout.Items.RemoveAt(0);
                //cbgin.Items.RemoveAt(0);
                foreach (MailsCategories mC in ms)
                {
    
                    Ext.Net.Checkbox ck = new Ext.Net.Checkbox();
                    ck.AutoWidth = true;
                   // ck.BoxLabel = "مرحبا";//mC.MailCategory_Name;
                    ck.FieldLabel = mC.MailCategory_Name;
                    ck.Tag = mC.MailCategory_ID.ToString();
                    for (int tempcatval = 0; tempcatval < arr.Length; tempcatval++)
                    {
                        if (arr[tempcatval] == mC.MailCategory_ID.ToString())
                        {
                            ck.Checked = true;
                            ck.Value = true;
    
                            break;
                        }
                    }
                    //ck.Checked = Convert.ToBoolean(false);
                    ck.InputValue = "cbResout" + i;
                    ck.LabelAlign = Ext.Net.LabelAlign.Left;
                    if (value == 0)
                    {
    
                        cbgout.Items.Add(ck);
                       
                    }
                    else
                    {
                        cbgin.Items.Add(ck);
                    }
                    i++;
    
                }
                if (value == 0)
                {
    
                    cbgout.AddTo(this.Paout);
                    //cbgout.Render();
                }
                else
                {
    
                    cbgin.AddTo(this.pain);
    
    
                }
    
                //stCategorymails.RefreshAfterSaving = Ext.Net.RefreshAfterSavingMode.Auto;
                //stCategorymails.DataSource = li;
                //stCategorymails.DataBind();
                cbgout.Visible = true;
                cbgin.Visible = true;
            }
        }
    //----------------------------------------------------------this java script code send the comand from the ext.net page to C# page---------------------//
     
    var loadingMsg = 'يرجى الانتظار جاري التحميل.....';
        function CommandHandler(employeeForm, command, record) {
           
            document.getElementById('hidevalu').value = record.data.Employee_ID;
            document.getElementById('hfHairarcyIDsuper').value = record.data.Hierarchy_SupervisorAtHierarchy_ID;
            var Empid = document.getElementById('hidevalu').value;
            if (command == 'Edit') {
          
                Ext.net.DirectMethods.CommandHandler(command, Empid);
                //        var form = employeeForm.getForm();
                //        form.items.items[0].setValue(record.data.Employee_Name);
                //        form.items.items[1].setValue(record.data.Employee_UserName);
                //        form.items.items[2].setValue(record.data.Employee_Password);
                //        form.items.items[4].setValue(record.data.Employee_EmailAdress);
                //        form.items.items[5].setValue(record.data.Employee_Position);
                //        form.items.items[6].setValue(record.data.Employee_IsFirstReciever);
                //        form.items.items[8].setValue(record.data.Employee_IsCTSEmployee);
                //        form.items.items[8].setValue(record.data.Group_ID);
                //        form.items.items[9].setValue(record.data.Hierarchy_ID);
                //        document.getElementById('hidevalu').value = record.data.Employee_ID;
                document.getElementById('HFupdat').value = -1;
            }
            else {
                Ext.Msg.confirm('حذف', 'هل انت متأكد من حذف المجموعة "' +
    		    record.data.Employee_Name + '" ?', function (btn) {
    		        if (btn == 'yes') {
    		            Ext.net.DirectMethods.CommandHandler(command, record.data.Employee_ID, { success: function (result) {
    		                Ext.Msg.show({
    		                    icon: Ext.MessageBox.INFO, msg: result, buttons: Ext.Msg.OK
    		                })
    		            },
    		                eventMask: {
    		                    showMask: true, msg: loadingMsg
    		                }
    		            });
    		            employeeForm.reset();
    		        }
    		        else {
    		            return;
    		        }
    		    });
    
            }
        }
    Last edited by Egale; May 04, 2011 at 7:49 PM.
  4. #4

    you see that

    Today when I was search for my problem in your community I found same my problem but they didn't show the solving for the problem

    in the flowing page

    http://forums.ext.net/showthread.php...checkbox-group

    in section (8) "CSG" found same my problem because he wanted 2 time to bring the data;

Similar Threads

  1. [CLOSED] Adding Checkboxes to Check Group in DirectEvent
    By amitpareek in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Sep 17, 2011, 4:50 PM
  2. Hidden check box group inside Accordion
    By Egale in forum 1.x Help
    Replies: 0
    Last Post: May 07, 2011, 8:41 AM
  3. Hidden check box group inside Accordion
    By Egale in forum 1.x Help
    Replies: 2
    Last Post: May 06, 2011, 7:46 PM
  4. [CLOSED] Drop down Field | Check Box Group
    By amitpareek in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Feb 19, 2011, 10:42 AM

Posting Permissions