We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Assign value on filter record

Hi All :

Good day, today, I have write a code for GridGroupControl as below:

GridDynamicFilter GridDfilter = new GridDynamicFilter();

gcAcSelect.TableDescriptor.Columns["ac_Select"].MappingName = "Chk";
                gcAcSelect.TableDescriptor.Columns["ac_Select"].Appearance.AnyRecordFieldCell.CheckBoxOptions.CheckedValue = "1";
                gcAcSelect.TableDescriptor.Columns["ac_Select"].Appearance.AnyRecordFieldCell.CheckBoxOptions.UncheckedValue = "0";
                gcAcSelect.TableDescriptor.Columns["ac_pNum"].MappingName = "ProductNum";
                gcAcSelect.TableDescriptor.Columns["ac_pNum"].AllowFilter = true;
                gcAcSelect.TableDescriptor.Columns["ac_pName"].MappingName = "ProductName";
                gcAcSelect.TableDescriptor.Columns["ac_pName"].AllowFilter = true;
                GridDfilter.WireGrid(gcAcSelect);

Above code that will show filter bar on Grid Grouping Control, then I create the 2 button which name "select all" and "clear all"
When user click select all, all filtered record will be check
The code as below
private void cmdAcAll_Click(object sender, EventArgs e)
        {
            foreach (Record rec in gcAcSelect.TableControl.Table.Records)
            {
                rec.SetValue("Chk", 1);
            }
        }

My problem is, when user click the select all button, the  unfiltered record are also be checked (i.e. Chk value = 1), how can prevent it ?

Pls advice

Thanks

Michael

3 Replies

PM Piruthiviraj Malaimelraj Syncfusion Team July 18, 2016 07:01 AM UTC

Hi Michael, 

Thanks for using Syncfusion products. 

We had analyzed your sample code. It seems that , you have used Table.Records collection to achieve your scenario. The Records collection will maintain the whole records of grid table (i.e. Filtered and unfiltered records). To achieve your scenario, FilteredRecords property of TableControl can be used. Because FilterRecords property will maintain the all the filtered records. Please make use of the below code. 

Code snippet 

private void button1_Click(object sender, EventArgs e) 
    foreach (Record rec in gridGroupingControl1.TableControl.Table.FilteredRecords
    { 
        rec.SetValue("CategoryID", 1); 
    } 

Sample link 

Regards, 
Piruthiviraj 



MK Michael K July 18, 2016 08:41 AM UTC

Dear Piruthiviraj:

Your message well note with thanks

Michael


PM Piruthiviraj Malaimelraj Syncfusion Team July 19, 2016 06:27 AM UTC

Hi Michael, 

Thanks for your update. 

Please let us know if you need any further assistance. 

Regards, 
Piruthiviraj. 


Loader.
Live Chat Icon For mobile
Up arrow icon