<ej-grid id="FlatGrid" allow-paging="true" datasource="ViewBag.dataSource" before-batch-add="beforeBatchAdd">
<e-edit-settings allow-editing="true" allow-adding="true" edit-mode="Batch"></e-edit-settings>
<e-toolbar-settings show-toolbar="true" toolbar-items='@new List<string> {"add","edit","update","cancel"}' />
<e-columns>
<e-column field="OrderID" is-primary-key="true" header-text="Order ID"></e-column>
<e-column field="CustomerID" header-text="CustomerID">
<e-edit-template create="Create" read="Read" write="Write">
</e-edit-template>
</e-column>
<e-column field="EmployeeID" header-text="EmployeeID"></e-column>
<e-column field="ShipCity" header-text="Ship City">
<e-edit-template create="CreateCity" read="ReadCity" write="WriteCity">
</e-edit-template>
</e-column>
</e-columns>
</ej-grid>
<script type="text/javascript">
function CreateCity() {
return $("<input>");
}
function WriteCity(args) {
var val = args.rowdata.OrderID;
--------
}
function ReadCity(args) {
var data = args.ejAutocomplete("getSelectedItems")[0];
if (!data)
return {};
return args.ejAutocomplete("getValue");
} |
<ej-grid id="FlatGrid" allow-paging="true" datasource="ViewBag.dataSource" before-batch-add="beforeBatchAdd" action-complete="complete">
<e-edit-settings allow-editing="true" allow-adding="true" edit-mode="Batch"></e-edit-settings>
<e-toolbar-settings show-toolbar="true" toolbar-items='@new List<string> {"add","edit","update","cancel"}' />
<e-columns>
<e-column field="OrderID" is-primary-key="true" header-text="Order ID"></e-column>
<e-column field="CustomerID" header-text="CustomerID">
<e-edit-template create="Create" read="Read" write="Write">
</e-edit-template>
</e-column>
<e-column field="EmployeeID" header-text="EmployeeID"></e-column>
<e-column field="ShipCity" header-text="Ship City">
<e-edit-template create="CreateCity" read="ReadCity" write="WriteCity">
</e-edit-template>
</e-column>
</e-columns>
</ej-grid>
<script type="text/javascript">
function complete(args) {
if (args.requestType == "refresh")
this.model.keyConfigs.saveRequest = "17";
} |
<ej-grid id="FlatGrid" allow-paging="true" datasource="ViewBag.dataSource" before-batch-add="beforeBatchAdd" action-complete="complete">
<e-edit-settings allow-editing="true" allow-adding="true" edit-mode="Batch"></e-edit-settings>
…..
<e-columns>
……………..
<e-column field="ShipCity" header-text="Ship City">
<e-edit-template create="CreateCity" read="ReadCity" write="WriteCity">
</e-edit-template>
</e-column>
</e-columns>
</ej-grid>
<script type="text/javascript">
function CreateCity() {
return $("<input>");
}
function WriteCity(args) {
………….
}
function ReadCity(args) {
var data = args.ejAutocomplete("getSelectedItems")[0];
……………….
return args.ejAutocomplete("getValue");
}
function beforeBatchAdd(args) {
var gridObj = $("#FlatGrid").data("ejGrid");
if (gridObj.batchChanges.added.length > 0) {
……………
if (gridObj.batchChanges.added[newestRowIdx].ShipCity != null) {
args.defaultData.ShipCity = gridObj.batchChanges.added[newestRowIdx].ShipCity;
}
}
}
|