The data seems to be persisted (alert behind the button "GetCurrentViewData" shows this) but the template column isn't properly refreshed.
var obj = $("#Grid").ejGrid("instance");
var data = obj.model.currentViewData;
|
function btnclick() {
var obj = $("#Grid").ejGrid("instance");
var data = obj.model.currentViewData;
var str="";
for (var i = 0; i < data.length; i++){
data[i].EmployeeID =i+1;
str=str+"\n"+data[i].EmployeeID+" : "+data[i].FirstName;
}
alert(str);
};
function btnfresh() {
var obj = $("#Grid").ejGrid("instance");
var str ="";
var data = obj.model.dataSource;
for (var i = 0; i < data.length; i++){
data[i].EmployeeID =i+1;
str=str+"\n"+data[i].EmployeeID+" : "+data[i].FirstName;
}
$("#Grid").ejGrid("refreshContent");
alert(str);
};
var droppedRow = function (args) {
var data = args.model;
var str="";
for (var i = 0; i < data.length; i++) {
model.dataSource[i].EmployeeID = i;
}
$("#Grid").ejGrid("refreshContent");
};
|
<div class="cols-sample-area">
<script type="text/x-jsrender" id="columnTemplate">
<img style="width: 75px; height: 70px" src="13.4.0.53/themes/web/images/Employees/{{:EmployeeID}}.png" alt="{{: EmployeeID }}" />
</script>
<script type="text/javascript">
function btnclick() {
. . .
data[i].EmployeeID =i+1;
};
function btnfresh() {
. . .
data[i].EmployeeID =i+1;
};
var droppedRow = function (args) {
. . .
model.dataSource[i].EmployeeID = i;
};
$(function () {
var grid = $("#Grid").ejGrid({
// the datasource "window.employeeView" is referred from jsondata.min.js
columns: [
{
headerText: "Employee Image", template: true, templateID: "#columnTemplate", textAlign: "center", width: 110 }
,
{
field: "EmployeeID", headerText: "Employee ID", isPrimarykey: true, editType: ej.Grid.EditingType.NumericEdit, textAlign: ej.TextAlign.Right, width: 90 }
}
. . . .
);
|
<script type="text/x-jsrender" id="columnTemplate">
<img style="width: 75px; height: 70px" src="13.4.0.53/themes/web/images/Employees/{{:Id}}.png" alt="{{: Id }}" />
</script>
var grid = $("#Grid").ejGrid({
// the datasource "window.employeeView" is referred from jsondata.min.js
dataSource: ej.DataManager(window.employeeView).executeLocal(ej.Query().take(8)),
editSettings: {
allowEditing: true, allowAdding: true, allowDeleting: true
}
,
allowRowDragAndDrop: true,
selectionType: "multiple",
columns: [
{
headerText: "Employee Image", template: true, templateID: "#columnTemplate", textAlign: "center", width: 110
}
,
{
field: "EmployeeID", headerText: "Employee ID", isPrimarykey: true, editType: ej.Grid.EditingType.NumericEdit, textAlign: ej.TextAlign.Right, width: 90
}
]
} |