ejs-checkbox in datagrid toolbar

Hi all, I would like to use, in my datagrid toolbar an ejs-checkbox to filter data.

I've tried to add a template item to toolbox using :

toolbarItems.Add(new {template = "<ejs-checkbox id='check' label='test' checked='' change='OnChange'></ejs-checkbox>", align = "right" })

without result.

I've solved with :

toolbarItems.Add(new {template = "<input type='checkbox' id='check1' onclick='handleClick(this);'> Show All</input>", align = "right" });

How can i have the same result with ejs-checkbox ?

Thanks in advance

Stefano


 


3 Replies

TS Thiyagu Subramani Syncfusion Team July 5, 2021 09:58 AM UTC

Hi Stefano, 
  
Thanks for contacting Syncfusion support. 
  
Based on your shared information we suspect that you want render our EJ2 checkbox in toolbar items. To achieve this requirement we suggest you to use below code blocks in your application. We have checkbox control using JavaScript way in created event. 
  
@{ 
    List<object> toolbarItems = new List<object>(); 
    toolbarItems.Add(new { template = "#menuitem", align = "right" }); 
} 
  
    <div id="menuitem"> 
        <input type="checkbox" class='check'/> 
    </div> 
  
<ejs-grid id="Grid"  created="created" toolbar="toolbarItems" allowFiltering="true" dataSource="@ViewBag.DataSource"> 
    <e-grid-columns> 
        . . . . . . .  . 
</ejs-grid> 
  
<script> 
    function created() { 
        var checkBoxObj = new ej.buttons.CheckBox({ checked: true, label: 'Show All' }); 
        checkBoxObj.appendTo(".check");  
    } 
</script> 
  
 
  
  
  
Please get back to us, if you need any further assistance. 
  
Regards, 
Thiyagu S 



SC Stefano Capobianco replied to Thiyagu Subramani July 6, 2021 04:17 AM UTC

Hi Thiyagu, your solution works very well. I suggest adding style="display: none;" to the div menuitem so the same is hidden when the page is created and the grid is created and populated.


Thanks

Stefano

 



TS Thiyagu Subramani Syncfusion Team July 7, 2021 05:15 AM UTC

Hi Stefano, 

Thanks for the update. 

We are happy to hear that the provided solution works at your end.  

Please get back to us if you need further assistance. 

Regards, 
Thiyagu S 


Loader.
Up arrow icon