<style type="text/css">
.eheader {
font-weight: bold;
border-bottom: 1px solid #c8c8c8;
background: #c8c8c8;
}
...
}
</style>
</head>
<body>
<div id="Grid"></div>
<script type="text/babel">
$(function(){
var pageSettings = { pageSize: 4 };
var editSettings = { allowEditing: true, allowDeleting: true, allowAdding: true };
var toolbarSettings = { showToolbar: true, toolbarItems: [ej.Grid.ToolBarItems.Add, ej.Grid.ToolBarItems.Edit, ej.Grid.ToolBarItems.Delete, ej.Grid.ToolBarItems.Update, ej.Grid.ToolBarItems.Cancel]};
var columns = [
{ field: "OrderID", headerText: "OrderID",isPrimaryKey:true, width: 90 },
{ field: "CustomerID", headerText: "Last Name", width: 90 },
{ field: "EmployeeID", headerText: "EmployeeID",foreignKeyField: "EmployeeID", foreignKeyValue: "FirstName", dataSource: window.employeeView,editTemplate:{create:"create",read:"read",write:"write"}, width: 90 },
];
ReactDOM.render(
<div id="Grid2">
...
<EJ.Grid id="Grid_1" dataSource = {window.gridData} editSettings={editSettings} toolbarSettings={toolbarSettings} allowPaging = {true} columns={columns} pageSettings={pageSettings} >
...
});
</script>
<script>
function create() {
return $("<input>");
}
function write(args) {
var gridObj = $(".e-grid").ejGrid("instance"); // Get grid object
var val = ej.isNullOrUndefined(args.rowdata["EmployeeID"]) ? "" : args.rowdata["EmployeeID"];
args.element.ejDropDownList({
width: "100%", dataSource: args.column[2].dataSource, value: args.rowdata.EmployeeID, fields: { text: "FirstName", value: "EmployeeID" },
headerTemplate: "<div class='eheader'><span>FirstName</span> <span class='emp'>EmployeeID</span></div>",
template: '<div><div class="ename"> ${FirstName} </div>' + '<div class="desig"> ${EmployeeID} </div><div>', //bound firstName value which is the foreignkeyvalue for employeeID column and with employeeID value
})
}
function read(args) {
return args.ejDropDownList("getSelectedValue"); //return the selected value in dropdown list
}
</script>
</body>
</html>
|
var columns = [
{ field: "OrderID", headerText: "OrderID",isPrimaryKey:true, width: 90 },
{ field: "CustomerID", headerText: "Last Name", width: 90 },
{ field: "EmployeeID", headerText: "Last Name",template:"{{:CustomerID}}-{{ :EmployeeID}}", width: 90 },
|
<div id="Grid"></div>
<script type="text/x-jsrender" id="caption">
{{:~GetFunction(value)}}
</script>
<script type="text/javascript">
$(function () {
var title = {
setTitle: function (arg, index) {
for (var i = 0; i < this.ctx.prop.dataSource.length; i++) {
if(this.ctx.root.EmployeeID == this.ctx.prop.dataSource[i].EmployeeID)
return this.ctx.prop.dataSource[i].FirstName + ' - '+ this.ctx.prop.dataSource[i].LastName;
}
},
};
$.views.helpers({ GetFunction: title.setTitle });
});
</script>
<script type="text/javascript">
$(function () {
// the datasource "window.gridData" is referred from jsondata.min.js
var data = ej.DataManager(window.gridData).executeLocal(ej.Query().take(50));
$("#Grid").ejGrid({
dataSource: data,
...
columns: [
{ field: "EmployeeID", headerText: "EmployeeID", template: "#caption", foreignKeyField: "EmployeeID", foreignKeyValue: "FirstName", dataSource: window.employeeView, width: 90 },
],
});
|
Your solution uses global javascript functions ("create", "write" and "read" functions), along with jQuery to retrieve the grid item. Can this be done using actual React components and props? Because from what I can see from the solution provided, SyncFusion "Reactjs Library" is the thinnest wrapper on top of the javascript library.
The only Reactjs piece here is the component declaration <EJ.Grid ... />. In which, any sort of customization beyond the basic "command button" feature would have to be done via globally scoped jQuery manipulation? Do I understand this correctly?