kendoui scheduler插入重复记录

时间:2014-01-15 10:35:25

标签: php json kendo-ui kendo-scheduler kendo-datasource

使用弹出编辑器创建记录时遇到问题。 我在动作php上收到模型中的两条记录,模型[0]错误(也许是第一行的getdata)模型[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>

THX Giulio的

1 个答案:

答案 0 :(得分:0)

您不应使用dataSource的 batch 选项。