0

使用弹出式编辑器创建记录时出现问题。我在我的操作 php 中收到模型中的两条记录,model[0] 是错误的(可能是 getdata 的第一行) model[1] 是好的

动作没有问题,但在数组模型中用两条记录调用。如何仅从弹出窗口发送记录?

我的代码:

 <?include $BUCKER_FRAMEWORK_PATH."/INC/TOP_APPLET_JQ.php"; ?>
          <div id="example" class="k-content">
<div id="window"></div>
<div id="scheduler"></div>

  <script type="text/x-kendo-template" id="schedulerTemplate">

<div class="k-edit-label">
    <label for="start">Start</label>
</div>
<div class="k-edit-field" data-container-for="start">
    <input data-role="datetimepicker" name="start" />
</div>
<div class="k-edit-label">
    <label for="end">End</label>
</div>
<div class="k-edit-field" data-container-for="end">
    <input data-role="datetimepicker" name="end" /></div>

<div>
 <div class="k-edit-label">
    <label for="title">Descrizione</label>
</div>  
<div class="k-edit-field" data-container-for="title">
    <textarea class="k-textbox" name="description" data-bind="value:description" required ></textarea>
</div>
<div class="k-edit-label">
    <label for="cliente">Cliente</label>
</div>
<div class="k-edit-field" data-container-for="cliente">
<input type="hidden" id="oldedtACCOUNT_NAME" name="oldedtACCOUNT_NAME" data-bind="value:accountname" />
<input  type="hidden" name="accountid" id="accountid" data-bind="value:accountid"/>
   <input class="inputboxPick" readonly type="text"  SIZE="25"  name="tmpACCOUNT_NAME"  id="tmpACCOUNT_NAME" data-bind="value:accountname" />
   <a id="href_kendoPickApplet" class="ui-button ui-widget ui-state-default ui-button-text-only"  href="\#" 
    onclick="KendoPickApplet('?module=accounts&applettype=pickapplet&CODICE=accountid&VALORE=tmpACCOUNT_NAME&addConstrain=&mode=action');return false;">
    <i class="icon-external-link"></i>
    <a id="cancel_ACCOUNT_NAME" class="ui-button ui-widget ui-state-default ui-button-text-only" href="\#" onclick="javascript:$('\#edtACCOUNT_ID').val('');javascript:$('\#tmpACCOUNT_NAME').val('');return false;">
    <i class="icon-remove"></i>    
    </a>

</div>
<!--
<div class="k-edit-label">
    <label for="type">Type</label>
</div>
<div class="k-edit-field" data-container-for="type">
    <input data-role="dropdownlist" id="type" data-bind='value:type' data-text-field='text' data-value-field='value' data-bind="source: dataSource2"/>
</div>
-->
<div class="k-edit-label">
    <label for="type2">Type</label>
</div>
<div class="k-edit-field" data-container-for="type">
    <input data-role="dropdownlist" id="type" data-bind='value:type' />
</div>
<script>
    $("\#type").kendoDropDownList({
        dataTextField: "text",
        dataValueField: "value",
        optionLabel: " ",
        //value:theId,
        dataSource: {
            transport: {
                read: {
                    dataType: "json",
                    url: "fetchj.php?type=PCK_EVENT",
                }
            }
        }
    });
<\/script>    
</div>

</script>



<script>

function onRequestEnd(e) {

    if (e.type == "create" || e.type == "update") {
        //check for errors in the response

        if (e.response.Esito=="OK") {
            setTimeout(function() {
                $.bootstrapGrowl(e.type+" record OK", {
                    type: 'success',
                    align: 'center',
                    offset: {from: 'top', amount: 2},
                    width: 'auto',
                    allow_dismiss: true
                   });

            })  
        } else {
           setTimeout(function() {
                //alert("error");
                $.bootstrapGrowl(e.response.Esito, {
                    type: 'danger',
                    align: 'center',
                    offset: {from: 'top', amount: 2},
                    width: 'auto',
                    allow_dismiss: true
                   });
            });
        }
        this.read();
    }
};  



$(function() {

var dataSource2 = new kendo.data.DataSource({
  transport: {
    read: {
      //url: "http://demos.kendoui.com/service/products",
      url: "fetchj.php?type=PCK_EVENT",
      dataType: "json"
    }
  }
});
    $("#scheduler").kendoScheduler({
        height: 600,
        editable: {
            template: kendo.template($("#schedulerTemplate").html())
        },

        views: [
            "day",
            "week",
            { type: "month", selected: true },
            "agenda"
        ],
        timezone: "Etc/UTC",
        dataSource: {
            transport: {
                read: { 
                    url: "?module=calendarskendo&applettype=server_cal&mode=action&action=getData",                    
                    dataType: "json"
                },
                update: {
                    url: "?module=calendarskendo&applettype=server_cal&mode=action&action=update",                    
                    dataType: "json"
                },
                create: {
                    url: "?module=calendarskendo&applettype=server_create&mode=action&action=create",                    
                    dataType: "json"

                },
                destroy: {
                    url: "http://demos.kendoui.com/service/meetings/destroy",
                    dataType: "jsonp"
                },

                /*
                parameterMap: function(options, operation) {
                    if (operation !== "read" && options.models) {
                        return {models: kendo.stringify(options.models)};
                    }
                }
                */
            },
            autoSync: false,
            batch: true,
            requestEnd: onRequestEnd,
            schema: {
                //data: "data",
                //total: "total",



                model: {
                    fields: {
                      id: { from: "TaskID" ,type: "text"},
                      phone : { from: "Phone" },
                      accountname : { from: "Accountname" },
                      accountid : { from: "Accountid" },
                      title: { from: "Title" },
                      type: { from: "Type" },                      
                      description: { from: "Description" },
                      start: { from: "Start", type: "date", format: "{0:yyyy-MM-dd}"},
                      end: { from: "End", type: "date", format: "{0:yyyy-MM-dd}"}
                    }
                }
            },

        },
    });
});


</script>
</div>

谢谢朱利奥

4

1 回答 1

0

您不应使用数据源的批处理选项。

于 2014-01-15T14:58:56.717 回答