<div id="basicDialog" >
<div id="Grid" style="margin-top:10px;"></div>
</div>
<script type="text/javascript">
$(function () {
$("#basicDialog").ejDialog({
showOnInit: true,
});
var data = ej.DataManager(window.gridData).executeLocal(ej.Query().take(50));
$("#Grid").ejGrid({
dataSource: data,
columns: [
{ field: "OrderID", headerText: "Order ID", width: 75, textAlign: ej.TextAlign.Right },
. . . .
]
});
$("#basicDialog_title").append("<input type="+"text"+" id="+"columnChooser"+" />");//appending a dropdown in the dialog's title
var columns = [//Datasource for the dropdown
{ skill: "Order ID", id: "OrderID" },
. . . .
{ skill: "OrderDate", id: "Order Date" }
];
$('#columnChooser').ejDropDownList({
dataSource: columns,
fields: { text: "skill",value:"id" },
showCheckbox: true,
checkAll: true, //Checks all the dropdown list at initial render
checkChange: "change"
});
});
function change(args){
var obj = $("#Grid").ejGrid("instance");
if(!args.isChecked)
obj.hideColumns(args.value);
else
obj.showColumns(args.value);
}
</script>
|