Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if a kendo grid contains specific item with javascript

I have an ASP.NET MVC project. In one view there is a Kendo Grid named FullNameList and there is only one column named FullName, there is bunch of data inside the grid; all of them are simple string names. I want to know if there is a method to check whether the kendo grid contains an specific item or not? If not how can I iterate through datasource items to check one by one the items?

like image 670
yekanchi Avatar asked Oct 20 '25 02:10

yekanchi


1 Answers

In the client (i.e. browser) the data source data can be searched using javascript Array some method:

var searchName = "Yekanchi";

var searchNameFound = $("#FullNameList").data("kendoGrid").dataSource.data().some(
  function (dataItem) {
    return dataItem.FullName == searchName;        
  });

Some

The some() method tests whether at least one element in the array passes the test implemented by the provided function. It returns a Boolean value.

like image 119
Richard Avatar answered Oct 21 '25 15:10

Richard