I have a common method which does some operations on kendo grid
instance. The caller can pass jQuery instance or actual kendo grid instance to this common method
function commomMethod(grid)
{
//?? How do i check if `grid` instance is not KendoGrid instance
if(grid is not kendoGrid)
{
grid = grid.getKendoGrid();
}
//do something
}
function caller1()
{
commomMethod($("#mygrid"));
}
function caller2()
{
commomMethod($("#mygrid").getKendoGrid());
}
Here is the working DEMO
Below is the code snippet from the demo:
function commomMethod(grid)
{
var kendoGrid = $(grid).data("kendoGrid");
//Check if the element is already initialized with the Kendo Grid widget
if (kendoGrid)//Grid is initialized
{
alert("Yess, Kendo grid is initialized");
}
else
{
//grid is not initialized
alert("Nopeee, Kendo grid not is initialized");
//To verify, you change the id here to $("#mygrid1").kendoGrid({
}
//do something
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With