Hi All,
I have `ticket` and `ticket_update` tables
if the `ticket`.`flag`="1" in condition `ticket_update` Child table - "Add New" Button to be hide
Thanks in Advance.
Child table - "Add New" Button hide with condition
Re: Child table - "Add New" Button hide with condition
Hi,
you can either check in the hooks/TABLENAME.php -> _dv function the condition and set the permissions to the child table accordingly,
or you can use JS on the detailview. You need to wait till the child table is loaded and then remove the Add New button. The second solution will require that you check the creation of the child record, as a user could bypass the missing "Add New" Button.
Hope that gives you a starting point
you can either check in the hooks/TABLENAME.php -> _dv function the condition and set the permissions to the child table accordingly,
or you can use JS on the detailview. You need to wait till the child table is loaded and then remove the Add New button. The second solution will require that you check the creation of the child record, as a user could bypass the missing "Add New" Button.
Hope that gives you a starting point
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Child table - "Add New" Button hide with condition
I had try with this below code, but its not working.
<script>
$j(function(){
$j('#status').each(function(){
var status = $j(this).text();
if (status =='Closed'){
$j('.btn.btn-success.hspacer-sm.vspacer-md').addClass('hidden');
alert($j('#status').text());
}
else {
$j('.btn.btn-success.hspacer-sm.vspacer-md').removeClass('hidden');
alert($j('#status').text());
}
})
})
</script>
<script>
$j(function(){
$j('#status').each(function(){
var status = $j(this).text();
if (status =='Closed'){
$j('.btn.btn-success.hspacer-sm.vspacer-md').addClass('hidden');
alert($j('#status').text());
}
else {
$j('.btn.btn-success.hspacer-sm.vspacer-md').removeClass('hidden');
alert($j('#status').text());
}
})
})
</script>
Re: Child table - "Add New" Button hide with condition
Hi,
once you checked if the status == 'Closed' you will have to check if the button is already loaded. The child table is loaded later, so your code would probably not catch the button yet.
once you checked if the status == 'Closed' you will have to check if the button is already loaded. The child table is loaded later, so your code would probably not catch the button yet.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Child table - "Add New" Button hide with condition
Thanks for the clue...
function wait_for(data,callback,time=60) {
if($j(data).length != 0) {
callback();
return;
}
else {
setTimeout(function() {
wait_for(data,callback, time);
}, time);
}
}
$j(function() {
wait_for(".btn.btn-success.hspacer-sm.vspacer-md", function() {
if($j('#status').text() == 'Closed'){
$j('.btn.btn-success.hspacer-sm.vspacer-md').addClass('hidden')
}
})
})
function wait_for(data,callback,time=60) {
if($j(data).length != 0) {
callback();
return;
}
else {
setTimeout(function() {
wait_for(data,callback, time);
}, time);
}
}
$j(function() {
wait_for(".btn.btn-success.hspacer-sm.vspacer-md", function() {
if($j('#status').text() == 'Closed'){
$j('.btn.btn-success.hspacer-sm.vspacer-md').addClass('hidden')
}
})
})