-1

I have made the html template and i am using that template in popup editor.If i have atleast one record in grid then it will perfectly but if there is no data in grid then if click on add button then custom popup editor will not open.There is no error given but popup editor not open.So anybody know solution of this problem?Thanks in advance. EDIT this is the template i have used.

<script id="teamEditorTemplate" type="text/x-kendo-template">
    <form  method="POST">
 <table>
            <tr>
                <td><div >
                        Area Prefix:                
                    </div></td>
                <td><div>
                        <input name="area_prefix" class="k-input k-textbox" style="text-align: left" id="area_prefix" required  validationMessage="Please Enter Area Prefix"/>                        
                    </div></td>
            </tr>
             <tr>
                <td><div >
                        Area Name:                
                    </div></td>
                <td><div>
                        <input name="area_name" class="k-input k-textbox" style="text-align: left" id="area_name" required  validationMessage="Please Enter Area Name"/>                        
                    </div></td>
            </tr>
             <tr>
                <td><div >
                        Source:                
                    </div></td>
                <td><div>
                        <input name="source" style="text-align: left" id="source" required  validationMessage="Please Select Source"/>                        
                    </div></td>
            </tr>
             <tr>
                <td><div >
                        Country Name:                
                    </div></td>
                <td><div>
                        <input name="vox_country_id" style="text-align: left" id="vox_country_id" required  validationMessage="Please Select Country"/>                        
                    </div></td>
            </tr>

   </table>
    </form>    
</script>

The kendo ui code is here

$("#grid").kendoGrid({
            dataSource: dataSource,
           pageSize: 10,
             serverPaging: true,
            serverSorting: true,
            sortable:true,
                pageable: { 
                            refresh: true,
                             pageSizes:[10,20,50,100]
                        },
            height: 400,
            toolbar: [{ name: "create", text: "Add New Area" }],
            columns: [
                { field:"area_prefix", title: "Area Prefix",width:70 },
                { field: "area_name", title:"Area Name",width:90},
                { field: "source", title:"Source",width:70, template: '#= getsourceName(source) #'},
                 { field: "vox_country_id", width:70,template: '#= getCountryName(vox_country_id) #'},
                { command: ["edit", "destroy"], title: "Action",width:53}],
            editable: {
                mode: "popup",            
                template: $("#teamEditorTemplate").html(),
                update: true,  
                add:true,
                destroy: true,

                confirmation: "Are you sure you want to remove ?"
            },
            edit: function(e) {
                if(!e.model.id){
                    $(e.container).parent().find('.k-window-title').html("Add Area Details");
                    $(e.container).parent().find('.k-grid-update').html("Save");
                }
             }
        });
4

1 回答 1

0

您的问题中缺少一个信息:您如何定义数据源以及什么是getsourceNameand getCountryName

试图重现您的问题,我写的内容DataSource如下:

var dataSource = new kendo.data.DataSource({
    data  : [],
    schema: {
        model: {
            id            : "id",
            fields        : {
                area_prefix   : { type: "string" },
                area_name     : { type: "string" },
                source        : { type: "string" },
                vox_country_id: { type: "string" }
            },
            getsourceName : function (d) {
                d = d || "hello";
                return d;
            },
            getCountryName: function (d) {
                d = d || "bye";
                return d;
            }
        }
    }
});

如果已定义且未定义或,则getsourceName返回其中一个(当前值) 。类似的。dnullhellogetCountryName

添加记录时,没有以前的值,很可能会引发一些错误,无法打开弹出窗口。

但是,如果方便地检查 null 那么它应该可以正常工作。

在此处查看我与您的代码放在一起的示例:http: //jsfiddle.net/OnaBai/wcZ3L/

于 2013-07-04T23:42:30.700 回答