0

我有一个像这样的剑道网格..

@(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()
)

在我的 javascript 中,我想获取列“团队”值的最大长度。我的意思是,我想找到列队所有值的数据字符串长度。可能吗。我熟悉使用客户端模板并将单个团队值传递给 javascript。但这曾经似乎很棘手。

4

2 回答 2

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.

于 2013-10-10T12:19:11.573 回答
0

我们可以使用此代码轻松设置最大长度

  model: {
                    id: "CLASSID",
                    fields: {
                        CLASSID: { type: "number" },
                        CLSNAME: { type: "string" },
                        CLSFLAG: {
                            type: "string", validation: {
                                required: true,maxlength:"3"
                            }
                        },
                        CLSSTATUS: { type: "boolean" }
                    }
                }
于 2018-09-23T08:54:04.700 回答