0

I have a kendo grid like this..

@(Html.Kendo().Grid<baseballViewModel>()
      .Name("baseball")
      .DataSource(dataSource => dataSource 
          .Ajax() 
          .Read(read => read.Action("Index", "baseball"))
          .ServerOperation(false)
          )
      .HtmlAttributes(new { style = "height:175px;" })
      .Columns(col => {
              col.Bound(player=> player.Date).Width(85);
              col.Bound(player=> player.Year).Width(55);
              col.Bound(player=> player.Name).Width(150);
              col.Bound(player=> player.team).Width(120);

      }).Sortable() 
        .Scrollable()
        .Pageable()
)

In my javascript I would like to get the column "team" values max length. I mean, I would like to find the data strings length of all the values of column team. Is it possible. I am familiar with using client template and passing individual team values to javascript. But this once seems to be tricky.

user1032957
  • 453
  • 1
  • 6
  • 16

2 Answers2

1

I'm assuming you want to add up the total length of every team length, and a team = a list.

I would do this by creating a foreach loop after you have fetched the data in your controller, looping through your results, and using the .Length property on each team list to add the value to a counting field, which you would then send to the model.

The alternative would be to access your grid with jQuery ie. $('#baseball').data('kendoGrid'), then loop through each row this way to store in a javascript variable.

Reece
  • 396
  • 3
  • 11
0

We can easily set the maximum length using this code

  model: {
                    id: "CLASSID",
                    fields: {
                        CLASSID: { type: "number" },
                        CLSNAME: { type: "string" },
                        CLSFLAG: {
                            type: "string", validation: {
                                required: true,maxlength:"3"
                            }
                        },
                        CLSSTATUS: { type: "boolean" }
                    }
                }
Prince Prasad
  • 1,528
  • 1
  • 16
  • 20