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

How can I format the date values in the filter list to remove the time value

I have date columns in a sfDataGrid and the data in the cells display date format mm/dd/yyyy but when I select the filter option the dates are listed in dd/mm/yyyy hh:mm:ss AM. I want the filter list to display the same format as the cell ( in this case mm/dd/yyyy).





4 Replies

SP Subburaj Pandian Veluchamy Syncfusion Team June 21, 2019 04:05 AM

Hi George, 
  
Thank you for using Syncfusion controls. 
  
You can achieve your requirement by set the FilterMode for a grid column asDisplayText in SfDataGrid. 
  
Please refer the below code example 
  
sfDataGrid.Columns["OrderDate"].FilterMode =ColumnFilter.DisplayText; 
  
  
  
  
Regards,
Subburaj Pandian V 
 



GB George Busby June 21, 2019 04:52 AM

That corrected the display issue but now it does not display the values in the filter pop up in chronological order. That may work for a small list but will not work at all on a large list. When I changed the FilterMode to "value" it lists the dates in chronological order but the time displays along with the date. I tried to set the Format property (mm/dd/yyyy) but that format is not used in the Filter pop up. ( I would think that if you format the display on the grid you would want the same format in the filter lookup)

Also, I was able to determine that the lower case "mm" always sets the value to 00 , if I use upper case MM the display works (MM/dd/yyyy).



AK Adhikesevan Kothandaraman Syncfusion Team June 24, 2019 06:16 AM

Hi George, 

Thanks for your patience. 

We are currently working on your query with high priority. We will get back to you with the complete details on this at 26th June, 2019. 
Thanks for your patience until then. 

Regards, 
Adhi  



AK Adhikesevan Kothandaraman Syncfusion Team June 27, 2019 03:37 AM

Hi George, 

Regret for the inconvenience caused. 

If you want to display the filter options in the chronical order with the given format, you can use the custom filter control and use the DrawItem event of the CheckedListBox to customize the display text as per your requirement. Please refer to the following code snippet and sample, 

Code Snippet: 
this.sfDataGrid1.FilterPopupShowing += sfDataGrid1_FilterPopupShowing; 
void sfDataGrid1_FilterPopupShowing(object sender, Syncfusion.WinForms.DataGrid.Events.FilterPopupShowingEventArgs e) 
{ 
    var customFilterControl = new CustomFilterControl(); 
    customFilterControl.Column = e.Column; 
    if (!(e.Control is CustomFilterControl)) 
    { 
        e.Cancel = true; 
        customFilterControl.Show(this.sfDataGrid1.TableControl, e.Location); 
    } 
} 
 
public class CustomFilterControl : DataGridFilterControl 
{ 
    bool itemDrawingWired = false; 
 
    protected override void SetCheckedListBox(Control control, System.Drawing.Point location, System.Drawing.Size size) 
    { 
        base.SetCheckedListBox(control, location, size); 
 
        if(this.CheckListBox != null && !itemDrawingWired) 
        {                 
            this.CheckListBox.DrawItem += CheckListBox_DrawItem; 
            itemDrawingWired = true; 
        } 
    } 
 
    void CheckListBox_DrawItem(object sender, Syncfusion.WinForms.ListView.Events.DrawItemEventArgs e) 
    { 
        if (e.ItemType == Syncfusion.WinForms.ListView.Enums.ItemType.SelectAllItem) 
            return; 
 
        if (this.Column is GridDateTimeColumn) 
        { 
            DateTime date; 
            if (DateTime.TryParse(e.Text, out date)) 
                e.Text = date.ToString("MM/dd/yyyy"); 
        } 
    } 
} 
 
 

Before checking the solution, Please install the following patch in your version 17.1.0.47 and patch for the fix can be downloaded from the following location.  
Recommended approach - exe will perform automatic configuration    
Please find the patch setup from below location:    
    
 
Advanced approach – use only if you have specific needs and can directly replace existing assemblies for your build environment   
Please find the patch assemblies alone from below location:    
     
Assembly Version: 17.1.0.47   
   
Installation Directions : This patch should replace the files “SfListView.WinForms” under the following folder.   
$system drive:\ Files\Syncfusion\Essential Studio\$Version # \precompiledassemblies\$Version#\[TargetFramework]   
Example : $system drive:\Program Files\Syncfusion\Essential Studio\17.1.0.47\precompiledassemblies\17.1.0.47\4.0    
    
To automatically run the Assembly Manager, please check the Run assembly manager checkbox option while installing the patch. If this option is unchecked, the patch will replace the assemblies in precompiled assemblies’ folder only. Then, you will have to manually copy and paste them to the preferred location or you will have to run the Syncfusion Assembly Manager application (available from the Syncfusion Dashboard, installed as a shortcut in the Application menu) to re-install assemblies.    
    
Note :    
To change how you receive bug fixes, ask your license management portal admin to change your project’s patch delivery mode.    
   
    
Disclaimer :    
Please note that we have created this patch for version 17.1.0.47 specifically to resolve the issue reported in this Forum 145425.    
    
If you have received other patches for the same version for other products, please apply all patches in the order received.    
The fix for this issue will be included in our upcoming 2019 Volume 2 SP1 release which is expected to be rolled out in the end of July, 2019.  
 
Regards, 
Adhi 


Loader.
Live Chat Icon For mobile
Up arrow icon