Cassie Mod

Cassie Mod

  • 1.5k
  • 488
  • 48.1k

check if Kendo grid contains item

Feb 28 2018 4:48 AM
HI, ive got the following question. We have a kendo grid.
but how can i check if the kendo grid contains a specific item ?
 
this is wat i have so far:
 
  1. <script>  
  2.       $(function() {  
  3.   
  4.           $('form').on('submit',  
  5.               function(e) {  
  6.   
  7.                   @* Add the data from the grids *@  
  8.                   var numbers = $("#NumberGrid").data('kendoGrid').dataSource.view().toJSON();  
  9.                   $('#@Html.IdFor(m => m.NumbersJson)').val(JSON.stringify(numbers));  
  10.   
  11.   
  12.                   // client side validation  
  13.                   var lineGroupId = $('#@Html.IdFor(m => m.LineGroupId)').val();  
  14.   
  15.                   // check if lineGroupId is in numbers (if value is set)  
  16.                   var lineGrouIdIsInNumbers = false;  
  17.   
  18.                   // code to check number in list  
  19.                   var numbersData = numbers.dataSource.data();  
  20.                   for (var i = 0; i < numbersData.length; i++) {  
  21.                        var numberdata = numbersData[i];  
  22.                        var number = numberdata.value;  
  23.                        if (number === lineGroupId) {  
  24.                            lineGrouIdIsInNumbers = true;     
  25.                      }  
  26.                   }  
  27.   
  28.                   if (lineGrouIdIsInNumbers === false) {  
  29.                       // enable button and change text  
  30.                       $("#submitButton").prop('disabled'false).val(valueOfSubmitButton);  
  31.   
  32.                       // show error message (under submit button)  
  33.   
  34.                       // return false ( or prevent default action)  
  35.                       e.preventDefault();  
  36.                       //return false;  
  37.                   }  
  38.               }); 
 However the page is crashing and i think it is because of my for loop to check if the number exists in the grid , so how can i fix this ?
 
thnx guys