[CLOSED] Adding item to CheckboxGroup group but can't set checked value

  1. #1

    [CLOSED] Adding item to CheckboxGroup group but can't set checked value

    Hi,

    i adding items to CheckboxGroup but i can't set checkbox checked value.

    How can i set checkbox check value by dynamically with add checkbox to CheckboxGrou?


    foreach (BolumClass clsProje in colProje)
            {
    
          // Doesn't work
          cbgProjeListesi.Items.Add(new Checkbox { BoxLabel = clsProje.Ad, InputValue = clsProje.ID.ToString(), Checked = CheckProject(clsProje.ID) });
    
         //Doesn't work
          var cb = new Checkbox { ID = "cb" + clsProje.ID.ToString(), BoxLabel = clsProje.Ad, InputValue = clsProje.ID.ToString() };
          cb.SetValue(true);
          cbgProjeListesi.Items.Add(cb);
            }
            cbgProjeListesi.Render();
    
    
     public bool CheckProject(int ID)
        {
            return true;
        }
    Last edited by Daniil; Feb 17, 2015 at 11:37 AM. Reason: [CLOSED]
  2. #2
    Hello ddeniz,

    I can't think on exactly is your scenario with the information you provided, so I am afraid I can do little to help you with guesses.

    Can you provide a simple working example on how to reproduce your issue, for example with a simple panel with the checkboxes and a button to simulate the dynamic adding process and the checkbox failing?

    Then we could work in detail and ultimately give you a good solution for your problem. :)

    Maybe this guide may help you in providing us a sample which we can use to better deal with your issue: Forum Guidelines for Posting new Topics.
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Hi fabricio.murta,

    Thanks for answer,
    My scenario is simple actually.

    I Have a user list page and when i click gridpanel i calling PersonDetail window (YetkiGuncelleFormu method) with ID parameter. (it's ok).
    getting person id (GelenID) from params. (it's ok).
    i have project list in db and i filling to my IEnumerable list (colProje) (it's ok).
    adding all projects to CheckboxGroup (it's ok) but when i adding checkbox to CheckboxGroup i can't set checked value only.
    there is a CheckProject method, this method has 2 paramateres (GelenID,ProjectID)
    i checking this person(GelenID) authorization for project (ProjectID) and returning true or false value.

    i hope i can tell my problem :)

    i waiting your answer.

    Thank you

    Do?an Deniz
    Best Regards

    
     <script type="text/javascript">
    
    
       var GuncelleButonuOlustur = function() {
                return '<img class="imgbGuncelle" ext:qtip="Click to view/edit additional details" style="cursor:pointer;" src="/icons/pencil-png/ext.axd" />';
            };
    
            var HucreTikla = function(view, cell, columnIndex, record, row, rowIndex, e) {
    
                var t = e.getTarget(),
                    columnId = this.columns[columnIndex].id; // Get column id
                //  alert(t.className + '->' + columnId);
                if (t.className == "imgbGuncelle" && columnId == "Guncelle") {
                    // YetkiIslemleri.YetkiGuncelle(parseInt(record.data.ID));
                    return true;
                }
                return false;
            };
    
     </script>
    
    
         <ext:GridPanel ID="gpKullaniciListesi" runat="server" ButtonAlign="Left" RowLines="true"
                            Frame="true" PageSize="25">
      <Store>
                                <ext:Store ID="stoKullaniciList" runat="server" PageSize="50">
                                    <Model>
                                        <ext:Model ID="Model4" runat="server" IDProperty="PersonelID">
                                            <Fields>
                                                <ext:ModelField Name="ID" Type="Int" />
                                                <ext:ModelField Name="YetkiID" Type="Int" />
                                                <ext:ModelField Name="PersonelID" Type="Int" />
                                                <ext:ModelField Name="Ad" />
                                                <ext:ModelField Name="Yetki" />
                                            </Fields>
                                        </ext:Model>
                                    </Model>
                                </ext:Store>
                            </Store>
    <ColumnModel ID="ColumnModel1" runat="server">
                                <Columns>
                                    <ext:Column ID="Column8" runat="server" DataIndex="Ad" Width="150" Text="Personel" />
                                    <ext:Column ID="Column5" runat="server" DataIndex="Yetki" Width="100" Text="Yetki" />
                                
                              
                                </Columns>
                            </ColumnModel>
     <Listeners>
                                <Render Handler="this.on('cellclick', HucreTikla);" />
                            </Listeners>
    <DirectEvents>
                                <CellClick OnEvent="YetkiGuncelleFormu">
                                    <EventMask ShowMask="true" CustomTarget="={#{gpKullaniciListesi}.body}" />
                                    <ExtraParams>
                                        <ext:Parameter Name="ID" Value="record.getId()" Mode="Raw" />
                                    </ExtraParams>
                                </CellClick>
                            </DirectEvents>
    </ext:GridPanel>
    
    
    protected void YetkiGuncelleFormu(object sender, DirectEventArgs e)
        {
    
           int GelenID = 0;
            if (!string.IsNullOrEmpty(e.ExtraParams["ID"]))
                int.TryParse(e.ExtraParams["ID"], out GelenID);
    
            var colProje = TanimlamalarDataClass.BolumIslemleri.PersonelProjeleri();
    foreach (BolumClass clsProje in colProje)
            {
    
          // Doesn't work
          cbgProjeListesi.Items.Add(new Checkbox { BoxLabel = clsProje.Ad, InputValue = clsProje.ID.ToString(), Checked = CheckProject(GelenID,clsProje.ID) });
    
         //Doesn't work
          var cb = new Checkbox { ID = "cb" + clsProje.ID.ToString(), BoxLabel = clsProje.Ad, InputValue = clsProje.ID.ToString() };
          cb.SetValue(CheckProject(GelenID,clsProje.ID));
          cbgProjeListesi.Items.Add(cb);
            }
            cbgProjeListesi.Render();
        }
    
    public bool CheckProject(int PersneID,int ID)
        {
             var clsPortalProjeList = dPersonel.PersonelPortalProjeListesi(PersonelID, ID);
            if (clsPortalProjeList == null) return false;
            return true;
        }
    
    
    
    <ext:Window ID="wnYetkiIslemleri" runat="server" AutoScroll="true" Icon="UserAdd"
            Title="Yetki ??lemleri" Width="700" MaxHeight="575" Modal="true" Resizable="false"
            AutoShow="false" Hidden="true">
            <Items>
                <ext:TabPanel ID="tpHesap" runat="server" AutoScroll="true" ActiveTabIndex="0" Border="false"
                    DeferredRender="false">
                    <Items>
                        <ext:Panel ID="pnlYetki" runat="server" Title="Yeni Kullan?c? Ekle" Layout="FormLayout">
                            <Items>
                                <ext:Hidden ID="hfYetkiID" runat="server">
                                </ext:Hidden>
                                <ext:ComboBox ID="cbYeniPersonelListesi" runat="server" InputWidth="350" TypeAhead="true"
                                    QueryMode="Local" ForceSelection="true" FieldLabel="Personel" TriggerAction="All"
                                    DisplayField="AdSoyad" ValueField="PersonelID" EmptyText="Personel Listesi...">
                                    <Store>
                                        <ext:Store ID="stoYeniPersonelListesi" runat="server">
                                            <Model>
                                                <ext:Model ID="Model3" runat="server">
                                                    <Fields>
                                                        <ext:ModelField Name="PersonelID" />
                                                        <ext:ModelField Name="AdSoyad" />
                                                    </Fields>
                                                </ext:Model>
                                            </Model>
                                        </ext:Store>
                                    </Store>
                                </ext:ComboBox>
                                <ext:ComboBox ID="cbYeniYetkiListesi" FieldLabel="Yetki" runat="server" Width="250"
                                    Editable="false" DisplayField="YetkiAdi" ValueField="ID" QueryMode="Local" TriggerAction="All"
                                    EmptyText="Yetki Listesi...">
                                    <Store>
                                        <ext:Store ID="stoYeniYetkiListesi" runat="server">
                                            <Model>
                                                <ext:Model ID="Model2" runat="server">
                                                    <Fields>
                                                        <ext:ModelField Name="ID" />
                                                        <ext:ModelField Name="YetkiAdi" />
                                                    </Fields>
                                                </ext:Model>
                                            </Model>
                                        </ext:Store>
                                    </Store>
                                </ext:ComboBox>
                                <ext:CheckboxGroup ID="cbgProjeListesi" runat="server" ColumnsNumber="1" Cls="x-check-group-alt"
                                    FieldLabel="Projeler">
                                </ext:CheckboxGroup>
                            </Items>
                            <Buttons>
                                <ext:Button Text="Kaydet" ID="btnKaydet" Icon="Disk" runat="server">
                                    <DirectEvents>
                                        <Click OnEvent="YeniYetkiliKaydet">
                                            <EventMask ShowMask="true" />
                                            <ExtraParams>
                                                <ext:Parameter Name="items" Value="getChecked(#{cbgProjeListesi})" Mode="Raw" Encode="true" />
                                            </ExtraParams>
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>
                                <%--<ext:Button ID="Button1" runat="server" Text="Show checked">
                                    <DirectEvents>
                                        <Click>
                                            <ExtraParams>
                                                <ext:Parameter Name="items" Value="getChecked(#{cbgProjeListesi})" Mode="Raw" Encode="true" />
                                            </ExtraParams>
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>--%>
                            </Buttons>
                        </ext:Panel>
                    </Items>
                </ext:TabPanel>
            </Items>
        </ext:Window>
  4. #4
    It might be a little bit difficult to put all the code snippets together and finally run the test case. Ideally, we should be able to copy, paste and run the code without any changes. Please see Example (Very Helpful) in the Forums GuideLines that Fabricio pointed to.

    This technique how to strip down the real world page to a test case might help.
    How to prepare a sample

    It is unlikely we are able to help you without a test case, because, it is hard to come up with a solution basing on the description and code snippets.
    Last edited by Daniil; Feb 06, 2015 at 12:50 PM.

Similar Threads

  1. [CLOSED] CheckBoxGroup Items Checked from DirectEvent
    By osef in forum 2.x Legacy Premium Help
    Replies: 6
    Last Post: Apr 01, 2014, 7:26 PM
  2. [CLOSED] Get Checked items of checkbox group
    By mohan.bizbites in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Oct 21, 2013, 5:02 PM
  3. [CLOSED] Adding Item to Checkbox group by Direct Event
    By amitpareek in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: May 31, 2010, 7:17 PM
  4. Replies: 7
    Last Post: Oct 27, 2009, 8:46 AM
  5. Replies: 1
    Last Post: Jun 01, 2009, 5:15 PM

Posting Permissions