Kendo ui 如何将ClientFooterTemplate值从DB而不是sum中放入

Kendo ui 如何将ClientFooterTemplate值从DB而不是sum中放入,kendo-ui,kendo-grid,kendo-asp.net-mvc,Kendo Ui,Kendo Grid,Kendo Asp.net Mvc,请理解我使用谷歌翻译是因为我的英语不流利 我想在网格的ClientFooterTemplate中输入某个值,而不是总和 它是一个列名,与要输出的位置的列值无关,并且不存在于网格列中 我想把它作为从db接收的值 如果OnDataBound事件中有多个查询结果值,则使用dataitem访问它,并将相应的值放入隐藏的文本框中 然后,我们尝试输入以下输出。 (我不知道如何使用clientFooterTemplate,所以我编写了一个JavaScript函数。) 按请求连接控制器读取和网格。 我在其他部分

请理解我使用谷歌翻译是因为我的英语不流利

我想在网格的ClientFooterTemplate中输入某个值,而不是总和

它是一个列名,与要输出的位置的列值无关,并且不存在于网格列中

我想把它作为从db接收的值

如果OnDataBound事件中有多个查询结果值,则使用dataitem访问它,并将相应的值放入隐藏的文本框中

然后,我们尝试输入以下输出。 (我不知道如何使用clientFooterTemplate,所以我编写了一个JavaScript函数。)

按请求连接控制器读取和网格。 我在其他部分使用RAZOR表达式,但在我要创建的部分中不使用它们

.ClientFooterTemplate("#: kendo.toString(fn_GetCnt(), '\\#\\#,\\#') #")

function fn_GetCnt () {
    return $ ("# ALO_03_CNT"). val ();
}

 public ActionResult ALO_Read([DataSourceRequest]DataSourceRequest request, string GUBUN, string ALO_ID, string ALO_01, string ALO_02ST, string ALO_02ED, string CAR_04, string RUT_04, int ALO_03, int ALO_04, string ALO_10, string RUT_04G, string CAR_05, string RUT_14, string ALO_05, string TMP2)
    {           
        testQuery Query = new testQuery();
        JsonResult returnJsonResult = new JsonResult();

        ALO_02ST = ALO_02ST.Replace("-", "");
        ALO_02ED = ALO_02ED.Replace("-", "");
        List<AloModels> list = Query.SP_ALO_SELECT(GUBUN, ALO_ID, ALO_01, ALO_02ST, ALO_02ED, CAR_04, RUT_04, ALO_03, ALO_04, ALO_10, RUT_04G, CAR_05, RUT_14, ALO_05, TMP2);

returnJsonResult = Json(list.ToDataSourceResult(request), 
JsonRequestBehavior.AllowGet);
returnJsonResult.MaxJsonLength = 2147483647;

        return returnJsonResult;
    }


  @( Html.Kendo().Grid<BUSCB.Models.AloModels>()
        .Name("grid")
        .DataSource(dataSource => dataSource
            .Ajax()
            .ServerOperation(true)
            .PageSize(20)
            .Read(read => read.Action("ALO_Read", "ANB").Data("readParam"))
            .Events(events => events
                .RequestEnd("onRequestEnd")
                .RequestStart("onRequestStart")
            )
        .Aggregates(aggregates =>
        {
            aggregates.Add(p => p.ALO_05).Sum();
            aggregates.Add(p => p.ALO_06).Sum();
            aggregates.Add(p => p.ALO_07).Sum();
            aggregates.Add(p => p.ALO_08).Sum();
            aggregates.Add(p => p.ALO_09).Sum();
            aggregates.Add(p => p.ALO_05_A).Sum();
            aggregates.Add(p => p.ALO_05_B).Sum();
        })
        )
    .Columns(columns =>
    {
    columns.Bound(o => o)
            .Width(30)
            .HeaderTemplate(@<text><input type='checkbox' id='selectAll' onclick="checkAll(this)" /></text>)
                .HtmlAttributes(new { style = "text-align:center" })
                .HeaderHtmlAttributes(new { style = "text-align:center" })
                .ClientTemplate("<input type='checkbox' #= isChecked ? checked='checked':'' # class='chkbx' />");         
        columns.Bound(o => o.CAR_04)
            .Title("Car No.")
            .Width(150)
            .ClientFooterTemplate("#: kendo.toString(fn_GetCnt(), '\\#\\#,\\#') #")
            .HeaderHtmlAttributes(new { style = "text-align:center;vertical-align:middle;" })
            .HtmlAttributes(new { style = "text-align:left;white-space:nowrap;" })
            .FooterHtmlAttributes(new { style = "text-align:right;white-space:nowrap;" });        
       })
        .HtmlAttributes(new { style = "height: 712px;", @class = "page1" })
            .Pageable(pageable => pageable
                .PageSizes(false)
                .Refresh(true)
                .ButtonCount(10)
                )
            .Scrollable()
            .Sortable()
            .Events(events => events
                .Change("OnRowClick")
                .DataBound("onDataBound")
            )               
            .ToolBar(tools => tools.Excel().Text("Excel"))
            .Excel(excel => excel
                .FileName(ViewBag.ExcelName)
                .AllPages(true)
                .Filterable(true)
                .ProxyURL(Url.Action("Excel_Export_Save", "AdminRegister")))
            .Reorderable(r => r.Columns(true))
            .Resizable(r => r.Columns(true))
            .Selectable()
    )
.ClientFooterTemplate(“\:kendo.toString(fn\u GetCnt(),'\ \ \ \ \ \ \,\ \ \ \ \ \ \”)\)
函数fn_GetCnt(){
返回$(“#ALO_03_CNT”).val();
}
公共操作结果ALO_读取([DataSourceRequest]DataSourceRequest请求,字符串GUBUN,字符串ALO_ID,字符串ALO_01,字符串ALO_02ST,字符串ALO_02ED,字符串CAR_04,字符串RUT_04,字符串ALO_03,int ALO_04,字符串ALO_10,字符串RUT_04G,字符串CAR_05,字符串RUT_14,字符串ALO_05,字符串TMP2)
{           
testQuery=新建testQuery();
JsonResult returnJsonResult=新的JsonResult();
ALO_02ST=ALO_02ST.替换(“-”,”);
ALO_02ED=ALO_02ED。替换(“-”,”);
List List=Query.SP_ALO_SELECT(GUBUN、ALO_ID、ALO_01、ALO_02ST、ALO_02ED、CAR_04、RUT_04、ALO_03、ALO_04、ALO_10、RUT_04G、CAR_05、RUT_14、ALO_05、TMP2);
returnJsonResult=Json(list.ToDataSourceResult(请求),
JsonRequestBehavior.AllowGet);
returnJsonResult.MaxJsonLength=2147483647;
返回returnJsonResult;
}
@(Html.Kendo().Grid())
.名称(“网格”)
.DataSource(DataSource=>DataSource
.Ajax()
.ServerOperation(真)
.页面大小(20)
.Read(Read=>Read.Action(“ALO_Read”,“ANB”).Data(“readParam”))
.Events(Events=>Events
.RequestEnd(“onRequestEnd”)
.RequestStart(“onRequestStart”)
)
.聚合(聚合=>
{
加上(p=>p.ALO_05).Sum();
aggregates.Add(p=>p.ALO_06).Sum();
aggregates.Add(p=>p.ALO_07).Sum();
aggregates.Add(p=>p.ALO_08).Sum();
aggregates.Add(p=>p.ALO_09).Sum();
加上(p=>p.ALO_05_A).Sum();
加上(p=>p.ALO_05_B).Sum();
})
)
.列(列=>
{
columns.Bound(o=>o)
.宽度(30)
.HeaderTemplate(@)
.HtmlAttributes(新的{style=“text align:center”})
.HeaderHtmlAttributes(新的{style=“text align:center”})
.ClientTemplate(“”);
columns.Bound(o=>o.CAR_04)
.标题(“车号”)
.宽度(150)
.ClientFooterTemplate(“\:kendo.toString(fn\u GetCnt(),'\ \ \ \ \ \ \ \,\ \ \ \ \ \”))\)
.HeaderHtmlAttributes(新的{style=“文本对齐:中心;垂直对齐:中间;”})
.HtmlAttributes(新的{style=“text align:left;空白:nowrap;“})
.footerHtmlatAttributes(新的{style=“text align:right;空白:nowrap;“});
})
.HtmlAttributes(新的{style=“height:712px;”,@class=“page1”})
.Pageable(Pageable=>Pageable
.页面大小(错误)
.刷新(真)
.按钮计数(10)
)
.Scrollable()
.Sortable()
.Events(Events=>Events
.Change(“OnRowClick”)
.数据绑定(“onDataBound”)
)               
.ToolBar(tools=>tools.Excel().Text(“Excel”))
.Excel(Excel=>Excel
.FileName(ViewBag.ExcelName)
.AllPages(真)
.可过滤(真)
.ProxyURL(Url.Action(“Excel\u导出\u保存”、“AdminRegister”))
.Reorderable(r=>r.Columns(true))
.可调整大小(r=>r.Columns(true))
.可选()
)
尽管它起到了预期的作用, 问题在于时机

它不是绘制接收到的alo_03_cnt值,而是在onDataBound完成之前绘制网格

(也就是说,如果再次搜索,alo_03_cnt的值将正确显示在页脚中。)


如何在绘制网格之前输入值?

能否显示配置网格和控制器代码的Razor代码的其余部分?我尝试使用控制器部分中的Viewdata执行grid.read,但无法获得值,无论该值在读取网格后是否消失。在那之后,我没有在控制器端做任何工作。在将执行网格读取的控制器上,查询结果的列表有一个CNT条目,并绑定到网格,但不会将其作为表输出。我无法直接表示这个绑定值,我想将这个值输出到一个隐藏变量。这是错误的方法吗?