PDA

View Full Version : [CLOSED] Treeview disabled checkbox



ucaneto
Nov 20, 2014, 4:18 PM
Is to make the column checkbox is disabled when the record is leaf?
Same as example http://examples2.ext.net/#/TreePanel/Advanced/TreeGrid/

Tks.

Ulisses

Daniil
Nov 20, 2014, 6:03 PM
Hi @ucaneto,

This example should help.
http://forums.ext.net/showthread.php?20436&p=88237&viewfull=1#post88237

ucaneto
Nov 20, 2014, 7:32 PM
Hello


I'm using treepanel and his screen is this:
http://forums.ext.net/attachment.php?attachmentid=16441&stc=1

and wish you were like:
http://forums.ext.net/attachment.php?attachmentid=16451&stc=1

I tried to do something using your example and not got it, you have to post an example of code with something?
in my case the test would be on Leaf

Tks..

Ulisses

Daniil
Nov 21, 2014, 4:51 AM
To check a node is a leaf or not, you can use the .isLeaf() method.
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.data.NodeInterface-method-isLeaf

Also you need hiding rather than disabling. Then you could use a "display: none;" rule instead of "background-image".

ucaneto
Nov 21, 2014, 12:10 PM
Hello Daniil


I did as you said and it worked, got the same screen that I showed, the only proble is that it lets you click the checkbox, I click and mark as not clicked, below is the code of the project, you can take a look and see why the problem?



<%@ Page Title="" Language="C#" MasterPageFile="~/programa/Site1.Master" AutoEventWireup="true" CodeBehind="frmMenus.aspx.cs" Inherits="SIF6.programa.cadastros.usuarios.frmMenus" %>


<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script type="text/javascript">
var myRenderer = function (value, metadata, record) {
var cssPrefix = Ext.baseCSSPrefix,
cls = [cssPrefix + 'grid-checkheader'],
editable = record.isLeaf();


if (value) {
cls.push(cssPrefix + 'grid-checkheader-checked');
}


if (!editable) {
cls.push("checkcolumn-disabled-" + (value ? "checked" : "unchecked"));
}


return '<div class="' + cls.join(' ') + '">*</div>';
}
</script>


<style type="text/css">
.checkcolumn-disabled-checked {
background-image: url(resources/images/checked-disabled.gif) !important;
}


.checkcolumn-disabled-unchecked {
background-image: url(resources/images/unchecked-disabled.gif) !important;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<ext:ResourceManager runat="server" />
<ext:Window
runat="server"
Plain="true"
Layout="FormLayout"
Width="610"
Height="316"
Closable="false"
ID="windowGrid"
Border="false"
Icon="MedalGoldAdd"
Title="Cadastro de Grupos"
Header="true">
<Items>


<ext:Panel
runat="server"
Width="600"
Height="400"
Layout="Border">
<Items>
<ext:TreePanel
runat="server"
EnableDrag="true"
DDGroup="tree2div"
Region="West"
Split="true"
Margins="5 0 5 5"
Width="500"
Height="300"
Header="false"
AutoScroll="true"
ID="treeCadastro"
Collapsible="false">


<%-- <TopBar>
<ext:Toolbar runat="server" Cls="custom-ext-toolbar ">
<Items>
<ext:ToolbarFill ID="ToolbarFill1" runat="server" />
<ext:Button ID="btnTreeExpand" runat="server" Icon="BulletTogglePlus" ToolTip="Expandir">
<Listeners>
<Click Handler="#{treeUceci}.expandAll();" />
</Listeners>
</ext:Button>
<ext:Button ID="btnTreeCollapse" runat="server" Icon="BulletToggleMinus" ToolTip="Minimizar">
<Listeners>
<Click Handler="#{treeUceci}.collapseAll();" />
</Listeners>
</ext:Button>
<ext:Button ID="btnTreeReload" runat="server" Icon="ArrowRefreshSmall" ToolTip="Atualizar">
<Listeners>
<Click Handler="treeRefresh(1,#{treeUceci});" />
</Listeners>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>--%>
<Listeners>
<%--<ItemClick Handler="if (record.data.href) { e.stopEvent(); loadPage(#{TabPanel2}, record); }" />--%>
</Listeners>


<Fields>


<ext:ModelField Name="diIncluir" Type="Boolean" />
<ext:ModelField Name="diAlterar" Type="Boolean" />
<ext:ModelField Name="diExcluir" Type="Boolean" />
</Fields>
<ColumnModel>
<Columns>
<ext:TreeColumn
runat="server"
Text="Menu"
Flex="2"
Sortable="true"
DataIndex="text" />
<ext:CheckColumn runat="server"
Text="Incluir"
DataIndex="diIncluir"
ID="chIncluir"
Width="40"
Editable="true"
StopSelection="false">
<Renderer Fn="myRenderer" />
</ext:CheckColumn>
<ext:CheckColumn runat="server"
Text="Alterar"
DataIndex="diAlterar"
Width="40"
Editable="true"
StopSelection="false">
<Renderer Fn="myRenderer" />
</ext:CheckColumn>
<ext:CheckColumn runat="server"
Text="Exluir"
DataIndex="diExcluir"
Width="40"
Editable="true"
StopSelection="false">
<Renderer Fn="myRenderer" />
</ext:CheckColumn>


</Columns>
</ColumnModel>
<Plugins>
<ext:CellEditing runat="server">
<Listeners>
<BeforeEdit Handler="if (!record.isLeaf()) {return false;} " />
</Listeners>
</ext:CellEditing>
</Plugins>
</ext:TreePanel>
</Items>
</ext:Panel>
</Items>
</ext:Window>
</asp:Content>


Tks..

Ulisses

ucaneto
Nov 21, 2014, 12:30 PM
Resolved, the post may close the error was here.



<Plugins>
<ext: CellEditing runat = "server">
<Listeners>
<BeforeEdit Handler = "if (record.isLeaf (!)) {Return false;}" />
</ Listeners>
</ ext: CellEditing>
</ Plugins>

Tks

Ulisses