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

Dynamic Filter - Customize/sort entries in filter list (Starts with, Ends with...)

Hi there,

is it possible to customize the dynamic filter list? 
I want to show only a small collection of entires and maybe sort them differently, so that 'Equals' is always on top and selected.

See attachment for clarity.

Thanks!

Attachment: dynFilter_2acf43f5.zip

8 Replies

AR Arulpriya Ramalingam Syncfusion Team June 12, 2017 12:36 PM UTC

Hi Oliver, 
 
Thanks for your interst in Syncfusion products. 
 
You can customize the DynamicFilter CompareOperator list by customizing the FilterBarCell model and renderer. The compareOprListBox.Items.AddRange() method can be used to add the compare operator items. Please make use of the below KB link to customize your own FilterCompareOperator list. 
 
 
Regards, 
Arulpriya 



OP Oliver Politzki June 13, 2017 05:36 AM UTC

Hello Arulpriya,

thank you for your answer. 

so do I have to use a CellModel AND a CellRenderer? Isn't there a simpler way to delimit the entires of the filter? :)

Because to me the example code from your post seems a little bit over the top / too much, for what I wanted to achieve. (Only showing a few entires).
I don't want new icons, just using the default ones.

Thank you! 




OP Oliver Politzki June 13, 2017 09:46 AM UTC

So I tried to rebuild your example and ended up with round about eight classes and God knows what else (and it still doesn't work the way I want), just to change the dynamic filter list? Really? 

This doesn't seem right. This can't possibly be the way, right?

This is waaaay too exaggerated. 


AR Arulpriya Ramalingam Syncfusion Team June 14, 2017 08:39 AM UTC

Hi Oliver, 

Thanks for your update. 

Query 
Response 
so do I have to use a CellModel AND a CellRenderer? Isn't there a simpler way to delimit the entires of the filter? :) 
The GridGroupingControl does not have the direct support to add only some CompareOperator to list in DynamicFilter. This can be achieved by only creating the custom CellModel and CellRenderer
just to change the dynamic filter list? Really? 

We have customized the sample as per requirement with some CompareOperator items. The operations done by the CompareOperators should be modified to customize the CompareOperator list. So these are the minimal classes should be added to CustomCellModel and CustomCellRenderer. Please make use of the provided sample. In the provided sample, the order of list can be changed in the list box CompareOperatorListPart of GridTableFilterBarExtCell.cs file as in the below code, 
 
//Add the compare operators in ListBox 
this.compareOprListBox.Items.AddRange(new string[] { "Equals","Expression Match","StartsWith", "EndsWith" }); 
 


 
Regards, 
Arulpriya 



OP Oliver Politzki June 21, 2017 09:14 AM UTC

Hi Arulpriya,

thank you for your help, I got it to work.

There is still one problem, though: 

If I'm typing in the textbox of the filter, the cursor always stays on / jumps to the beginning of the textbox. So if I wanted to insert something in the middle of my input, the cursor will jump to the beginning and my new typed text will be inserted at the end of the textbox.

I saw that the OnKeyPress and OnKeyDown methods are overridden in your example, but I haven't figured out yet, where this "jump to beginning" is happening in the code.

Thanks!


Attachment: CursorBeginning_61a8d9fd.zip


AR Arulpriya Ramalingam Syncfusion Team June 22, 2017 09:56 AM UTC

Hi Oliver, 
 
Thanks for your update. 
 
We have modified the sample as per your requirement. Please refer to the below modified code part in OnKeyPress event of the GridTableFilterBarExtCellRenderer class and make use of the modified sample. 
 
Code snippet 
 
protected override void OnKeyPress(KeyPressEventArgs e) 
{ 
  -----Some codes---- 
int prevSelectionStart = TextBox.SelectionStart; 
string newText = TextBoxText.Remove(TextBox.SelectionStart, TextBox.SelectionLength); 
string s = newText.Insert(TextBox.SelectionStart, (!Char.IsControl(e.KeyChar) ? e.KeyChar.ToString() : string.Empty)); 
s = s.ToUpper(); 
if (this.ValidateString(s)) 
  { 
    if (this.NotifyCurrentCellChanging()) 
    { 
        CurrentCell.IsModified = true; 
        SetTextBoxText(s, true); 
 
        if (charCode != 8 && charCode != 22 && charCode != 0) 
            TextBox.SelectionStart = prevSelectionStart + 1; 
     } 
 } 
  ------Some codes ------ 
} 
 
 
Regards, 
Arulpriya 



OP Oliver Politzki June 22, 2017 12:55 PM UTC

Hello Arulpriya,


thank you, it works!



AR Arulpriya Ramalingam Syncfusion Team June 23, 2017 04:15 AM UTC

Hi Oliver, 
  
Thanks for your update. 
  
We are glad to hear that the provided solution resolved your problem. Please let us know if you need further assistance. 
  
Regards, 
Arulpriya 


Loader.
Up arrow icon