【问题标题】:Issue with kendo, no data in the grid剑道问题,网格中没有数据
【发布时间】:2016-05-25 08:49:04
【问题描述】:

从现在开始我一直在寻找这个!所以我希望有人能提供帮助。

这是一个大项目,所以我不能全部放在这里,但是如果您需要更多代码,请告诉我,我会添加它。

所以我有一个网格,应该包含我的数据库中的内容。但是我得到了一个 k-no-data,不知道为什么。

这是我的网格:

<section id="main-content">
<section class="wrapper site-min-height">
    <div class="row">
        <div class="col-lg-10 main-chart">
            <div class="border-head">
                <h3>Results</h3>
            </div>
            <div class="col-lg-12 col-md-3 col-sm-12">
                <div class="showback">
                    <h4>Text example</h4>
                    <div class="panel panel-info">
                        <div class="panel-body">
                            @(Html.Kendo().Grid<DisplayGridResultatsPrestations>
                                ()
                                .Name("GridListeIdcc")
                                .Columns(columns =>
                                {
                                    columns.Bound(c => c.CategoriePrestation);
                                    columns.Bound(c => c.DesignationPrestation);
                                    columns.Bound(c => c.ValeurPreconisee);
                                    columns.Bound(c => c.ValeurProposee);
                                    columns.Bound(c => c.DesignationResultat);
                                })
                                .Filterable()
                                .Selectable(selectable => selectable.Mode(GridSelectionMode.Single).Type(GridSelectionType.Row))
                                .DataSource(datasource => datasource
                                .Ajax()
                                .Read(reader => reader.Action("THISISCONFIDENTIAL", "Comparaison", new { identifiantResultatsComparaison }))
                                .Model(model =>
                                {
                                    model.Id("Id");
                                })
                                .Group(group => group.Add(c => c.SOMETHINGCONFIDENTIALTOO))
                                .ServerOperation(true)))
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>

function onSelection(arg) 
{
    var grid = $("#GridListeIdcc").data("kendoGrid");
    var selectedItem = grid.dataItem(grid.select());
}

所以我认为它应该可以工作,但什么也没发生我只是在我的网格上有一个标题但没有价值。

我知道这不是很清楚,但如果我错过了一些重要的事情,我想你会告诉的。

public JsonResult THISICONFIDENTIAL([DataSourceRequest] DataSourceRequest request,
        string identifiantResultatsComparaison)
    {
        var resultats = _resultatComparaisonService.FindResultatById(identifiantResultatsComparaison);

        var listePrestations = resultats.ListeDesPrestationsApresComparaison;
        List<DisplayGridResultatsPrestations> diplayListeResultats = listePrestations.Select(prestation => new DisplayGridResultatsPrestations
        {
            CCN = prestation.NomAccordSante + " (" + prestation.IdentifiantAccordSante + ")",
            IdentifiantAccord = prestation.IdentifiantAccordSante,
            CategoriePrestation = prestation.CategoriePrestation,
            NomPrestation = prestation.NomPrestation,
            Resultat = prestation.ResultatComparaison,
            ValeurPreconisee = prestation.ValeurPreconisee,
            ValeurProposee = prestation.ValeurProposee,
            DesignationPrestation = prestation.DesignationPrestation,
            DesignationResultat = (prestation.ResultatComparaison) ? "OK ✔" : "KO ✘"
        }).ToList();

        return Json(diplayListeResultats.ToDataSourceResult(request, c => new
        {
            c.CategoriePrestation,
            c.CCN,
            c.IdentifiantAccord,
            c.DesignationPrestation,
            c.Resultat,
            c.DesignationResultat,
            c.ValeurPreconisee,
            c.ValeurProposee
        }), JsonRequestBehavior.AllowGet);

【问题讨论】:

  • 一些截图将有助于理解我猜想的问题。您拥有的所有选择选项都是默认选项,因此只需使用 .Selectable() 就可以了。您的具体问题是什么?
  • 我知道这会很棒,我的问题是我的信息来自 mongo 数据库。而且它们没有显示在我的网格内!
  • 你在你的控制器方法中看到你的信息了吗?
  • 是的,我看到了。我的 id 也包含好一个
  • 数据是如何返回到网格的?假设您正在点击正在读取数据的控制器。

标签: jquery asp.net-mvc kendo-ui


【解决方案1】:

好的。感谢您发布读取控制器的签名。这很有帮助。

您需要做的就是从以下位置对网格上的读取方法进行简单更改:

.Read(reader => reader.Action("THISISCONFIDENTIAL", "Comparaison", new { identifiantResultatsComparaison }))

.Read(reader => reader.Action("THISISCONFIDENTIAL", "Comparaison").Data("identifiantResultatsComparaison"))

通过像这样声明读取函数,它告诉读取操作从您的 identifiantResultatsComparaison javascript 函数中获取附加数据。

然后有一个函数可以像这样返回你的字符串:

function identifiantResultatsComparaison(){
   var mystringValue = '';
  //do something here 

 return { identifiantResultatsComparaison: mystringValue }
}

希望这很清楚您需要做什么,但如果不是,我会为您提供更新扩展答案。

【讨论】:

  • 这对我不起作用,没有调用该函数。警报没有触发。不知道为什么
  • 所以如果您查看浏览器的开发工具,您是否看到控制台中有任何抛出错误的内容?
  • 是的,我有这个 GET localhost:51665/Scripts/kendo.all.min.js LancerComparaison:40 GET localhost:51665/Scripts/kendo.fr-FR.js
  • 和这个 LancerComparaison:43 GET localhost:51665/Scripts/globalize.culture.fr-FR.js LancerComparaison:42 GET localhost:51665/Scripts/globalize.js 404 (Not Found) LancerComparaison:47 GET localhost:51665/Content/js/modernizr.js LancerComparaison:83 Uncaught TypeError: jQuery(...).kendoGrid不是函数(匿名函数)@LancerComparaison:83c @jquery-1.9.1.min.js:3p.fireWith @jquery-1.9.1.min.js:3b.extend.ready @jquery-1.9.1.min .js:3H@jquery-1.9.1.min.js:3
  • 如果您没有找到错误,那么这可以解释为什么您没有得到任何回复/按预期工作。您是否检查过 Kendo.all.min.js 文件是否存在于项目中被调用的位置?如果您检查并确保这些脚本文件包含在您的项目中,那么一切都应该开始为您正常工作。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-09-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-09-28
  • 2016-04-18
  • 1970-01-01
相关资源
最近更新 更多