...
<div id="Grid"></div>
<div id="basicDialog" title="Alert!!!">
<label>No records selected !!! </label>
<br />
<input class="e-btn" id="btnOpen" style="left: 35%; position: absolute; top:45px" value="OK" />
</div>
<script type="text/javascript">
$(function () {
$("#Grid").ejGrid({
...
toolbarClick: function (args) {
if ((args.itemName == "Edit" || args.itemName == "Delete") & this.getSelectedRecords().length == 0) {
alert = function () { }; //prevent the default alert popup
//here you can call your own customize alert method
$("#basicDialog").ejDialog("open");
}
},
columns: [
...
]
});
$("#basicDialog").ejDialog({
width: 300,
showOnInit:false, //dialog will not show on initial rendering
});
$("#btnOpen").ejButton({ size: "medium", click: "onOpen", type: "button", height: 30, width: 70 }); //rendered ok button
});
</script>
<script>
function onOpen(args) {
$("#basicDialog").ejDialog("close"); //close the dialog when clicking the button
}
</script>
</body>
</html>
|
Thanks!! It works perfectly!
In addition, I'd like to know if it's possible to prevent the default alert message (image 1) in grid and to show the customised alert dialog (image 2).
Image 1
Image 2
I will be awaiting for your reply, thanks again!
Regards, Luis.
Hi again.
This solution is in ASP.NET, could you provide me a solution only with javascript? please. Also, I would like to see an example using http://jsplayground.syncfusion.com/ in order to understand it better.
I will be awaiting for your reply, thanks again.
Regards, Luis Carlos.
<script type="text/x-jsrender" id="Content">
<tr><td>Order ID:</td><td>{{:OrderID}}</td></tr>
. . .
</script>
<div id="Grid"></div>
<script type="text/javascript">
$(function () {
var temp = $.templates("#Content");
$("#Grid").ejGrid({
dataSource: window.gridData,
allowPaging: true,
dataBound: function (args) {
$("#GridConfirmDialog_wrapper").prepend("<div id='GridConfirmDialog_title' class='e-titlebar e-header e-draggable e-js' tabindex=''><span class='e-title'>Delete Confirmation Dialog</span></div>")
$("#GridConfirmDialog").ejDialog({
beforeOpen: function (args) {
var gridobj = $("#Grid").data("ejGrid");
var data = gridobj.model.currentViewData[gridobj.model.selectedRowIndex];//get the details of the selected record
$("#GridConfirmDialog").find(".details").remove();
$("#GridConfirmDialog").prepend("<div class= details><table>" + temp.render(data) + "</table></div>")// prepend the selected record details to the ejDialog
}
});
},
});
});
</script> |
Hi again.
Maybe I didn't explain well, let me try it again.
What you're doing in your example (http://jsplayground.syncfusion.com/40ogajiw) is adding a "div" element HTML to the "ejDialog" component. While, I would like to remove the "ejDialog" component and create a new component (example: alert(); or customiseFunction();) with the same event listener in the button with label "OK".
Please, if you find a solution, let me know as soon as possible, thanks in advance.
Regards, Luis Carlos.
<div id="Grid"></div>
<script type="text/javascript">
$(function () {
window.alert = function (txt) { //triggers when alert method is called
createCAlert(txt); // method can be used to customize the alert message
}
$("#Grid").ejGrid({
dataSource: window.gridData,
allowPaging: true,
editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true, showDeleteConfirmDialog: false },
toolbarClick:function(args){ //triggers when clicking delete icon in grid
if (args.itemName == 'Delete' && this.getSelectedRecords().length)
alert("Are you sure you want to delete this records?");
//show the alert message instead of showing ejDialog
},
...
columns: [
...
]
});
});
</script>
<script>
function createCAlert(txt) {
//here you can customize the alert box";
}
</script> |