ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: Rimokas on September 21, 2021, 06:14:11 pm
-
Hi,
have some problems with toolbars.
1-st - Exist possibility to enable/disable toolbar buttons, like in the contextMenu? In contextMenu is option "disabled" - so I can control this. How to control buttons in toolbar for conditions from record ?
2-nd - I'm formatting toolbar from database table with php ... It return object of items. One problem, from php return as json object. So javascript function name in object for listener is as string, for example - listener: { click: "grid_gen" } . Then to click on this button, it runs here ( from 6773 line )
_onEvent: function(e, n, r) {
return function(i) {
var o = r.type;
"checkbox" == o ? r.value = t(i.target).prop("checked") : r.value = t(i.target).val(), n.call( e, i ), "file" == o && t(this).val("")
}
},
It fails in n.call() . I tried, to change it to "window[ n ].call( e, i )" . Then it run ... But if in function have confirmation or other dialogs it not run ...
How to run own function from string as I wanna ? How to override "listener" methods ?
Or maybe I something don't understanding, how to work with toolbars ... :-\. Sorry, but documnetation and samples not helped to me ...
Thanks ...
-
1. Add options.disabled: true to the toolbar control
options:{
disabled: true
},
2. use
listener: obj["grid_gen"]
where
var obj = {grid_gen: function(){
...
}}
-
Thanks for the answers! :)
with the second - I did what you directed ... but it's not working with confirmation dialog "Yes" or "No" .
I added jpg picture ... In debugger you can see that direction to function exist ... until confirm . It not appears ... :-\
It return nothing - no error, no reaction ... :( How to solve that ?
confirm - jqueryui dialog with defered :
window.confirm = function( message_confirm )
{
var defer = $.Deferred();
$( '<div/>', { title: 'Question!', 'class': 'confirm', 'id': 'dialogconfirm', text: message_confirm } )
.dialog(
{
buttons:
{
Taip: function()
{
defer.resolve( "yes" )
$( this ).attr( 'yesno', true)
$( this ).dialog( 'close' )
},
Ne: function()
{
defer.resolve( "no" )
$( this ).attr( 'yesno', false )
$( this ).dialog( 'close' )
}
},
close: function()
{
if ( $( this ).attr( 'yesno' ) === undefined )
{
defer.resolve( "no" )
}
$( this ).remove()
},
draggable: true,
modal : true,
resizable: false,
width : 'auto',
hide : { effect: "fade", duration: 300 }
})
return defer.promise()
}
-
Ok, I solved dialog problem with another popup solution - it's working ...
Thank you! ;D