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

Filtering selected columns in sfdatagrid

Hi,

I am developing an application in WPF. I have some doubts regarding the sfDatagrid and Ribbon Backstage. Please help me in solving these problems.

1. How to set the filtering only for selected Columns.

For Example: If I have a datagrid which is generated dynamically, let us say I have 10 columns and I want to pass a count dynamically (say 3), I want to set the filtering only to those number of columns (in this case 3 columns) and rest of columns shouldnt have any filtering in the sfdatagrid. How to acheive this?

2. How to place the contents of sfdatagrid cells 'center' aligned?

3. I am having a RibbonWindow in my application, I want to set the backstage to the startup of the application, and i dont want to display back button when backstage is set as a startup window. 

it can be acheived in Window Forms using the below code, please let me know how to do it using WPF.
this.backStageView1.ShowBackStage();
https://www.syncfusion.com/kb/2794/how-to-show-backstage-during-the-start-of-the-application


4. How to add an empty row to sfDatagrid?

Please suggest me for all the above queries.

Thanks and Regards,
nagaraj 

1 Reply

SV Srinivasan Vasu Syncfusion Team May 16, 2017 01:45 PM UTC

Hi Nagarajaswamy, 
 
Thanks for contacting Syncfusion support. 
 
 
Query 1: 
How to set the filtering only for selected Columns. 
 
 
We have analyzed your query and we have prepared a sample base on your requirement. You can enable AllowFiltering as true for columns based on given count dynamically.  
 
Code Example: 
  // Count should not exceed the datagrid columns count. 
 
if (Textbox.Text != null) 
        { 
                for (int i = 0; i < Convert.ToInt32(Textbox.Text); i++) 
                 
                    this.SfdataGrid.Columns[i].AllowFiltering = true; 
                } 
            }           
 
If you want apply Filtering programmatically, you can achieve this by using GridColumn.FilterPredicates property. 
 
Please refer the below UG Link to more about Filtering. 
 
 
 
 
 
Query 2: 
 
 How to place the contents of sfdatagrid cells 'center' aligned? 
You have set TextAlignment property as center for particular column to set center alignment for content. 
 
Code Example: 
 
<syncfusion:GridTextColumn MappingName="ID" TextAlignment="Center" /> 
 
 
If you have set AutoGenerateColumns as true, you have to set each column TextAlignment as like below, 
 
private void grid_AutoGeneratingColumn(object sender, AutoGeneratingColumnArgs e) 
        { 
            e.Column.TextAlignment = TextAlignment.Center; 
        } 
 
 
Query 3: 
 I am having a RibbonWindow in my application, I want to set the backstage to the startup of the application, and i dont want to display back button when backstage is set as a startup window.  
 
We have prepared a sample to meet your requirement. In this sample, we have called the “ShowBackStage” method of Ribbon control to show the BackStage window while loading. 
 
In your update, you have mentioned “I don’t want to display back button when backstage is set as a startup window”. Here, if your requirement is not to display the BackButton in BackStage window, we have collapsed its Visibility in the sample by getting this button using VisualUtilities in BackStageLoaded event. 
 
 
Query 4: 
 
How to add an empty row to sfDatagrid? 
You can add empty row with SfDataGrid by using UnBoundRow. 
 
Please refer the below UG Link: 
 
 
 
 
Regards, 
Srinivasan 


Loader.
Live Chat Icon For mobile
Up arrow icon