dqroktbn005028 2014-12-12 11:39
浏览 36

剑道模板无法读取/刷新网格

I have a general grid that list a serie of processes each one with a sub-grid with the participants of each process.

Just like this

Here is the code:

              $("#grid").kendoGrid({
                        dataSource: {
                            type: "json",
                            data: <?php echo $datos_procesos; ?>,
                            pageSize: 20
                        },
                        sortable: true,
                        filterable: {
                            extra: false,
                            operators: {
                                string: {
                                    startswith: "Empieza con",
                                    eq: "Igual a",
                                    neq: "No es igual a",
                                    contains: "Contiene",
                                    endswith: "Termina con"
                                }
                            }
                        },
                        selectable: "multiple",
                        pageable: {
                            refresh: true,
                            pageSizes: true,
                            buttonCount: 5
                        },
                });

                function detailInit(e) {
                    var detailRow = e.detailRow;

                    detailRow.find(".tabstrip").kendoTabStrip({
                        animation: {
                            open: { effects: "fadeIn" }
                        }
                    });

                    detailRow.find("#participantes").kendoGrid({
                        dataSource: {
                            type: "json",
                            data: <?php echo $datos_usuarios; ?>,
                            serverPaging: false,
                            pageSize: 7,
                            filter: { field: "IDPROCESO", operator: "eq", value: e.data.IDPROCESO }
                        },
                        scrollable: false,
                        sortable: true,
                        pageable: {
                            refresh: true
                        },
                        filterable: {
                            extra: false,
                            operators: {
                                string: {
                                    startswith: "Empieza con",
                                    eq: "Igual a",
                                    neq: "No es igual a",
                                    contains: "Contiene",
                                    endswith: "Termina con"
                                }
                            }
                        },
                        columns: [
                            { field: "NOMBRE", title:"Nombre" },
                            { field: "EMAIL", title:"Email" },
                            { field: "ACCIONES", title: "", encoded: false },
                        ]
                    });

                    $("a[id^='delete']").kendoTooltip({
                        content: "Desasignar usuario",
                        position: "top"
                    });

                    $("a[id^='delete']").click(function(event){
                        event.preventDefault();
                        var u = $(this).attr("href");

                        $.ajax({
                              url: u
                            }).success(function() {
                              alert("Se ha desasignado al usuario del proceso.");
                            }).error(function() {
                              alert("Se ha producido un error al desasignar el usuario del proceso.");
                            });
                        });
                    });

The html code is just a simple lines

             <div id="grid"></div>

            <script type="text/x-kendo-template" id="template">
                <div class="tabstrip">
                     <ul>
                        <li class="k-state-active">
                            Participantes
                        </li>

                     </ul>
                    <div>
                        <div id="participantes"></div>
                    </div>

                </div>
            </script>

All works fine, the grids are displayed correctly, the data come from a php function which extracts from database the processes and the participants of each one.

My problem comes when I try to delete a participant of a process, I want to refresh or read the new updated data but It doesnt work.

If I click in link created a[id^='delete'] it calls a php function through ajax deleting the participant but then I cant reload the grid in the success callback. The "pageable: {refresh: true}" property also doesnt work

I have several problems like "Cannot read property 'dataSource' of undefined" or "Cannot read property 'read' of undefined"

I am new with the kendoUI and I am a bit lost, if anyone could give me a clue it would be appreciated.

Thanks for the help

  • 写回答

1条回答 默认 最新

  • dtx63505 2014-12-12 12:50
    关注

    I would suggest to use command line destory in participantes sub-grid. Kendo Grid handles removing item from sub-grid and you don't need to load data again.

    detailRow.find("#participantes").kendoGrid({
        dataSource: {
            transport: {
                read:  {
                    url: //here url where sub grid data is read,
                    dataType: "jsonp"
                },
                destroy: {
                    url: // here server side url which removes particpant,
                    dataType: "jsonp"
                },
                parameterMap: function(options, operation) {
                    if (operation !== "read" && options.models) {
                        return {models: kendo.stringify(options.models)};
                    }
                }
            },
            serverPaging: false,
            pageSize: 7,
            filter: { field: "IDPROCESO", operator: "eq", value: e.data.IDPROCESO }
        },
        scrollable: false,
        sortable: true,
        pageable: {
            refresh: true
        },
        filterable: {
            extra: false,
            operators: {
                string: {
                    startswith: "Empieza con",
                    eq: "Igual a",
                    neq: "No es igual a",
                    contains: "Contiene",
                    endswith: "Termina con"
                }
            }
        },
        columns: [
            { field: "NOMBRE", title:"Nombre" },
            { field: "EMAIL", title:"Email" },
            { field: "ACCIONES", title: "", encoded: false },
            { command: ["destroy"], title: "&nbsp;" }],
        ]
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)