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

Can I have a sample for the datagrid search form ?

Hi, 

I'm very interested to the Search form for the SfDatagrid that I see on the online demos (see attached image).
But I don't find the code example on my own installation.
Is there a link where I can download the code example ?
Thank you in advance.

Silvio

Attachment: Syncfusion_98d35bfd.zip

5 Replies

SP Sowndaiyan Paulpandi Syncfusion Team January 20, 2016 12:57 PM UTC

Hi Silvio,

Thanks for contacting Syncfusion Support.

We have provided this “search” support from our Essential Studio Volume 4, 2015 (Version 13.4.0.53). So we recommend you to use our latest version 13.4.0.53 to use this “search” support and is available for download under the following link.
 

https://www.syncfusion.com/forums/121657/essential-studio-2015-volume-4-final-release-v13-4-0-53-is-available-for-download                                             

Regards,

Sowndaiyan



SI Silvio January 23, 2016 07:54 AM UTC

I've tried the search control and it works.
However I had to make 2 changes on your code not to have crashes on my own example.

First of all: 

       static SearchControl()
        {
          DefaultStyleKeyProperty.OverrideMetadata(typeof(SearchControl), new FrameworkPropertyMetadata(typeof(SearchControl)));
        }

        public SearchControl()
        {
        }

I have inserted the static constructor and the OverrideMetadata is called inside it. Otherwise, the second time you create the same control you'd have a crash.


Secondly, I had to make this change:


        private void OnComboBoxSelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
          if (e.RemovedItems.Count == 0 || e.AddedItems.Count == 0)
            return;
            var oldItem = e.RemovedItems[0];
            var newItem = e.AddedItems[0];
            if (oldItem == null || newItem == null)
                return;
            var oldGrid = this.GetDataGrid(oldItem.ToString());
            var newGrid = this.GetDataGrid(newItem.ToString());
            oldGrid.SearchHelper.ClearSearch();
            newGrid.SearchHelper.AllowFiltering = (bool)this.ApplyFilterCheckBox.IsChecked;
            newGrid.SearchHelper.Search(SearchTextBox.Text);
        }

Without the inserted red lines I had cases (closing the form) where e.AddedItems was empty and an IndexOfRangeException was thrown.

Now I have a question for you. This control seems to search for only Text cells. But what about searching also for combo-box value cells? Should it be possible ?

Have a nice day !


GL Ganeshkumar Lingappan Syncfusion Team January 25, 2016 05:39 PM UTC

Hi Silvio,

ComboBox column loads content presenter to provide support for template. You can enable search in combobox column by loading TextBlock by writing custom renderer. We have prepared and attached the sample for the ComboBox column Search for your Reference. Find the sample from below location.

Sample Location : https://www.syncfusion.com/downloads/support/forum/121720/ze/CS2017765198

Please let us know if you need further assistance.

Regards,
Ganeshkumar


SI Silvio January 26, 2016 04:25 PM UTC

Thank you for your assistance.
It works with GridComboBoxColumn.

Is there a similar example also with GridMultiColumnDropDownList ?

Thank you in advance.


AS Ambarish Srinivasan Syncfusion Team January 27, 2016 11:26 AM UTC

Hi Silvio,

By default search supported with GridMultiColumnDropDownList. Please find the sample where search working fine without any changes,
Sample

Regards,
Ambarish.

Loader.
Up arrow icon