|
function saveState(args) {
var gridObj = $("#Grid").ejGrid("instance");
var dropDownObj = $('#list').ejDropDownList("instance");
var state = {
cols: gridObj.model.columns
}
var object = JSON.stringify(state);//converting object to string
…..
function applyState(args) {
var gridObj = $("#Grid").ejGrid("instance");
var obj = $('#list').ejDropDownList("instance");
var value = obj.model.value;
//Post the saved (in ejDropDownlist) time
//To retrieve the Grid objects
$.ajax({
type: "POST",
url: "/Home/Restate",
data: { "dropObject": value },
success: function (data) {
var obj = JSON.parse(data);
if (obj.cols)
gridObj.columns(obj.cols);
else
gridObj.refreshContent();
…..
|
|
<ej-grid id="Grid" datasource="(IEnumerable<object>)ViewBag.dataSource" action-complete="onActionComplete" allow-paging="true" allow-filtering="false" SelectionType="Single" show-column-chooser="true">
<e-columns>
…..
</e-columns>
</ej-grid>
<script type="text/javascript">
function onActionComplete(args) {
if(args.requestType == "columnchooser"){
var gridObj = $("#Grid").ejGrid("instance");
var dropDownObj = $('#list').ejDropDownList("instance");
var state = {
cols: gridObj.model.columns
}
var object = JSON.stringify(state);//converting object to string
$.ajax({
type: "POST",
url: "/Home/Query",
data: { "gridObj": object },//posting the grid object as string
success: function (data, status, xhr) {
//On Success save the data which is the time
//based on the time saving of Grid object in the db takes place
var TempData = [];
var obj = $('#list').ejDropDownList("instance");
if (!ej.isNullOrUndefined(obj.model.dataSource))
TempData = obj.model.dataSource;
TempData.push({ dataTime: data, text: data });
$('#list').ejDropDownList("destroy");
//destroy and update the dropdownlist's dataSouce
$('#list').ejDropDownList({ dataSource: TempData })
},
});
}
} |