This is a migrated thread and some comments may be shown as answers.

Hide the Toolbar

2 Answers 744 Views
Grid
This is a migrated thread and some comments may be shown as answers.
monsoon
Top achievements
Rank 1
monsoon asked on 11 Jul 2013, 08:23 AM
Hi,
I had a requirement that,in a grid I have  the Tool bar which contains two custom created buttons  (search,delete) .I need to disable the toolbar by default and need to enable when user clicked 'Edit' button and this Edit button is not a part of grid.
I am using  kendo ui web,Framework .
It would be a great help if you suggest me with sample codes in jsfiddle or jsbin.Thanks in Advance.
MyTemplate:
$("#UseGrid").kendoGrid(
{  
dataSource : DataSource,
editable : true, 
height : 260,                          //Need to disable this toolbar and enable it by clicking grid independent Edit button
toolbar:'<div id=\"toolbar\" class=\"toolbar\"><button class=\"k-button\" id=\"search1\" title=\"Search\" onclick=\"openSrch(this);\"/><button id=\"deleteButton\" class=\"k-button sg-button-icontext view-delete\" title=\"Delete\" onclick=\"deleteRow();\"/></div>',

columns : [
{
field : "select",
title : "Select",
width : "16%",
template: "<input type='checkbox' class='checkbox' />"
},
{
field : "name",
title : "Name",
width : "35%"
}] 
});


Regards,
Winds

2 Answers, 1 is accepted

Sort by
0
monsoon
Top achievements
Rank 1
answered on 12 Jul 2013, 10:10 AM
One  way of doing it is like...(there may be still more efficient way  :) )
Grid definition :
 
$("#UrGridName").kendoGrid({columns : [
{
command: {text:'Edit',
click:function(e){myCustomFunction();}
}],...});
------------------Have a custom Function which set  mode value 
function myCustomFunction(){  mode="0";}
--------------------
Edit button will call onCLick_EditButton() using onclick attribute...

function onCLick_EditButton(){
$('#UrGridName .k-grid-toolbar').each(function() {
if(mode == "0"){
this.style.display='none'; // this hide the Toolbar
}else{
this.style.display=''";  // this display the Toolbar
}
});
}
----------

0
Iliana Dyankova
Telerik team
answered on 15 Jul 2013, 07:32 AM
Hi Winds,

If I understand your scenario correctly (at least from the code snippet in your last post), you would like to hide the Grid toolbar buttons. I am afraid this is not supported out-of-the-box in Kendo UI Grid and you need custom implementation (I think your current approach is suitable). 

If you would like to disable toolbar buttons - this is also not supported, however as a possible solution you could cover the buttons with a transparent <div> element and remove it when the 'Edit' button is clicked.
  

Regards,
Iliana Nikolova
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
monsoon
Top achievements
Rank 1
Answers by
monsoon
Top achievements
Rank 1
Iliana Dyankova
Telerik team
Share this question
or