JSFiddle - React, Tailwind, and code Playground
by ksgsharma
HTML
<script src="http://knockoutjs.com/downloads/knockout-2.2.0.js"></script>
<div data-bind='NEGrid: VM_AHISGrid'>
</div>
JavaScript
/*----------------------------------------------------------------------*/
/* View Model
/*----------------------------------------------------------------------*/
function AHISViewModel() {
var self = this;
self.VM_AHISGrid;
// I want this method to be invoked
self.goBackward = function () {
alert('I m Backward')
};
//fnDesignGrid
self.fnDesignGrid = function () {
self.VM_AHISGrid = new ko.NEGrid.viewModel({
data: self.GridItems,
columns: [{
headerText: "Address",
rowText: "AHIS_Address"
}, {
headerText: "City",
rowText: "AHIS_Addr_City"
}, {
headerText: "State",
rowText: "AHIS_Addr_State"
}, {
headerText: "Zip",
rowText: "AHIS_Addr_Zip"
}],
pageSize: self.gridRowCount(),
gridName: 'ALST_NE_GRID'
});
}
}
var vmAhis;
/*----------------------------------------------------------------------*/
/* KO Page Binding */
/*----------------------------------------------------------------------*/
$(document).ready(function () {
// create the model
vmAhis = new AHISViewModel();
ko.applyBindings(vmAhis);
});
/*----------------------------------------------------------------------*/
/* KO GRID CLASS , THIS CODE GOES INTO A SEPERATE JS FILE */
/*----------------------------------------------------------------------*/
(function () {
ko.NEGrid = {
// Defines a view model class you can use to populate a grid
viewModel: function () {
var self = this;
// This is getting invoked but I dont want it to be called
self.goBackward = function () {
//alert('I m Backward')
};
}
};
//...