Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have question about Json .

I have Json data that is 36 array .

each these array have 3 property . (MonthValue,CountValue,TypeValue).

I want To Make Condition that bring me

only result that typeValue is 2.

this my whole code


JavaScript
$(function () {
      $.ajax({
          type: 'POST',
          dataType: 'json',
          contentType: 'application/json',
          url: '@Url.Action("GetProviderReport")',
          data: '{}',
          success: function (result) {


              debugger;
              var data = new google.visualization.DataTable();
              data.addColumn('number', 'CountValue');
              data.addColumn('number', 'MonthValue');

              for (var i = 0; i < result.length; i++) {

                  data.addRow([result[i].CountValue, result[i].MonthValue]);
              }
              debugger;
              var chart = new google.visualization.AreaChart(document.getElementById('chartdiv3'));
Posted
Comments
deepakdynamite 26-Jan-15 7:28am    
Why don't you add this directly in GetProviderReport ??
Kornfeld Eliyahu Peter 26-Jan-15 7:31am    
If you are using only part of the return values it is much better to not to return them at all...Filter them on the server side!

1 solution

It would be best to handle this server side as mentioned in the comments already. You could ass typeValue as a parameter to the method GetProviderReport so you can also reuse it for other typeValues.

In the foreach you would need an if statement because the condition in the foreach would terminate the loop entirely if the condition is false.

Good luck!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900