Method not fired when no records selected in TreePanel

  1. #1

    [CLOSED] Method not fired when no records selected in TreePanel

    On the form places TreePanel and ComboBox. When I change combobox some data must be taken from TreePanel or alert must be showed if no records selected. But if no records selected in TreePanel SelectedItemActivationComboBoxSelect not fired by select event. How I can do it?
    <ext:ComboBox ID="SelectedItemActivationComboBox" ValueField="categoryId" DisplayField="category" Editable="false" Disabled="true" Margins="15 0 15 0" Flex="1" runat="server">
    	<Store>
    		<ext:Store runat="server" ID="SelectedItemActivationComboBoxStore">
    			<Model>
    				<ext:Model runat="server" ID="SelectedItemActivationComboBoxStoreModel">
    					<Fields>
    						<ext:ModelField Name="categoryId" />
    						<ext:ModelField Name="category" />
    					</Fields>
    				</ext:Model>
    			</Model>
    		</ext:Store>
    	</Store>
    	<DirectEvents>
    		<Select OnEvent="SelectedItemActivationComboBoxSelect">
    			<ExtraParams>
    				<ext:Parameter Name="nodeId" Value="#{SourceDbTreePanel}.getSelectionModel().getSelection()[0].data.id" Mode="Raw" />
    				<ext:Parameter Name="categoryId" Value="#{SelectedItemActivationComboBox}.getValue()" Mode="Raw" />
    			</ExtraParams>
    		</Select>
    	</DirectEvents>
    </ext:ComboBox>
    Last edited by QuAzI; Jun 05, 2014 at 3:20 PM.
  2. #2
    Hi @QuAzI,

    I think there is a JavaScript error here.
    Value="#{SourceDbTreePanel}.getSelectionModel().getSelection()[0].data.id"
    If there is no record selected, then a getSelection call returns an empty array and indexing [0] causes a "not defined error".

    So, do you need to fire a DirectEvent if no selection? If no, then
    <Select OnEvent="SelectedItemActivationComboBoxSelect" Before=" return #{SourceDbTreePanel}.getSelectionModel().hasSelection();">
    Returning false from a DirectEvent's Before prevents that DirectEvent.

    If you need to pass "-1", for example, then:
    <ext:Parameter 
        Name="nodeId" 
        Value="#{SourceDbTreePanel}.getSelectionModel().hasSelection() ? #{SourceDbTreePanel}.getSelectionModel().getSelection()[0].data.id : -1" 
        Mode="Raw" />
  3. #3
    Thats great! Thanks

Similar Threads

  1. Replies: 7
    Last Post: Mar 25, 2013, 12:02 PM
  2. [CLOSED] Update records subcollection with set() method?
    By PatrikG in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Oct 26, 2010, 12:29 PM
  3. Treepanel how to get selected node without using a Ajax event or method ?
    By lordofthexings in forum Examples and Extras
    Replies: 5
    Last Post: May 26, 2010, 12:02 PM
  4. How can I determine in onCommand method which command has been fired ?
    By n_s_adhikari@rediffmail.com in forum 1.x Help
    Replies: 3
    Last Post: Oct 16, 2009, 2:31 PM
  5. [CLOSED] Get selected gridpanel records
    By reinout.mechant@imprss.be in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Aug 31, 2009, 7:05 AM

Tags for this Thread

Posting Permissions