2014-01-15 76 views
0

使用彈出式編輯器創建記錄時出現問題。 我收到我的動作在模型中的兩個記錄,模型[0]是錯誤的(也許第一行getdata)模型[1]是好的kendoui調度程序插入重複記錄

有沒有問題的行動,但被稱爲兩記錄在陣列模型中。我怎樣才能發送只彈出的記錄?

我的代碼:

<?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 朱利奧

回答

0

你不應該使用的數據源的batch選項。