Grid Filter Custom Conditions

1 Answer 302 Views
Filter Grid
Akhil
Top achievements
Rank 1
Akhil asked on 29 Nov 2022, 05:27 AM
Model:
Public Int Id{get;set}
Public string Desc{get;set}
Public bool IsValid;set}
In Grid column bound filter added a client Template as :
columns.Bound(c => c.isValid).Filterable(f => f
            .Cell(c => c.Template("MyBooleanCellTemplate"))
            ).ClientTemplateId("isValid").Title("Valid");


<script id="isValid" type="text/x-kendo-template">
    #if(isValid){#
        <i style='color:green;font-size:20px;' class='k-icon k-i-check'></i>
    #}else{#
        <i style='color:red;font-size:20px;' class='k-icon k-i-x'></i>

    #}#
</script>

<script>
    function MyBooleanCellTemplate(args) {
        
        var radioInput = $("<input type='checkbox'/>"); 
        var wrapper = args.element.parent();
        var inputName = kendo.guid.
        
        args.element.remove(); 

        var labelTrue = $("<label/>")
            .text("")
            .append(radioInput); 

        radioInput.attr(kendo.attr("bind"), "checked:value") // Add the "bind" attribute, specify the unique and, and set a value.
            .attr("name", inputName)
            .val("true");
        wrapper.append([labelTrue]); 
    };
</script>
This will result in a view like this




When we check the box only true values are shown
When we uncheck the box only false values are shown
When we click filter clear button shows both true and false

Our aim is to

1.We don’t need to show the Filter clear button only on this column
2.Checking the box only show true values
3. Uncheck the box show both true and false values.

How can we achieve the above behavior like customize the grid filter conditions.

1 Answer, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 01 Dec 2022, 04:00 PM

Hi Akhil,

Thank you for reaching out.

I noticed that there is not a Telerik UI for ASP.NET Core license associated with your account which limits the availability of our support services for the product.

In this regard, It is recommended that you either purchase or renew your license in order to gain benefit from the latest updates, fixes, features, and support regarding the Telerik UI for ASP.NET Core components on the premise.

More information regarding the currently available plans can be reviewed here:

That being said, in regard to the first inquiry, I noticed that my colleague has already provided an answer within your previously opened forum thread.

Nevertheless, here is a revised version of the previously attached Telerik REPL example in the forum following your currently utilized configuration whilst omitting the Filter clear button:

That being said, when it comes to the Grid's filtering,  you can review the available filter operators that can be utilized in the dataSource API section. The filter configuration also supports setting the logic.

From the description provided I can suggest reviewing the Filter component and in particular this Demo of the DataSource and Grid integration which you can use in order to get a better grasp of how the aforementioned filters and logics can be utilized for the Grid's DataSource:

I hope this helps.

Kind Regards,
Alexander
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Filter Grid
Asked by
Akhil
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Share this question
or