Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: CommandButton code

  1. #1
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,893

    CommandButton code

    Hi all.
    I'm trying to implement a search box "universal" for all section.
    Name:  Screenshot - 20_02_2015 , 09_02_21.jpg
Views: 284
Size:  19.2 KB
    Name:  Screenshot - 20_02_2015 , 09_03_09.jpg
Views: 283
Size:  31.5 KB

    I can create the various controls, but I have a problem, when I press the "search" button, how can I do riferiemnto the values set in the combobox?

    this is the code:
    Code:
    //////////////////////////////////////////////////////////////////////////////
    proc sem_AddSectionSearchPanel(psTable)
    //////////////////////////////////////////////////////////////////////////////
    
    	sp_container = createObject("container")
    	sp_container.addObject("osp_combo", "Combobox")
    	sp_combo = osp_combo
    	osp_combo.move(5, 3, 80, 20)
    		
    	select(psTable)
    	
    	afields(laAllFields)
    	for lnI = 1 to alen(laAllFields, 1)
    		osp_combo.additem(laAllFields(lnI, 1))
    	endfor
    
    	sp_container.addObject("osp_comboCondition", "Combobox")
    	sp_comboCondition = osp_comboCondition
    	osp_comboCondition.move(85, 3, 80, 20)
    	
    	select(psTable)
    	
    	osp_comboCondition.additem("Uguale")
    	osp_comboCondition.additem("Maggiore di")
    	osp_comboCondition.additem("Minore di")
    	osp_comboCondition.additem("Compreso")
    	osp_comboCondition.additem("Contenente")
    
    	sp_container.addObject("osp_textbox", "textbox")
    	sp_textbox = osp_textbox
    	sp_textbox.tooltip = psTable
    	osp_textbox.move(165, 3, 100, 20)
    	sp_container.addObject("sp_search", "commandbutton")
    	sp_search.move(270, 3, 60, 20)
    	sp_search.text = "Search"
    	sp_search.click = sp_search_handler
    	sp_search.tooltip = psTable
    	sp_container.addObject("sp_clear", "commandbutton")
    	sp_clear.move(335, 3, 60, 20)
    	sp_clear.text = "Reset"
    	sp_clear.click = sp_reset_handler 
    	this.addSearchPanel(sp_container)
    endproc
    
    ////////////////////////////////////////////////////////////////
    // handlers for the Search Panel
    proc sp_search_handler()
    ////////////////////////////////////////////////////////////////
    	private sp_mainTable, sp_comboCondition, sp_combo, sp_textbox
    	sp_mainTable = ""
    	sp_comboCondition = ""
    	sp_combo = ""
    	sp_textbox = ""
    	
    	oActivePage = lianja.activepage
    	ActicePage = oActivePage.id
    	oActiveSection = Lianja.get(ActicePage).activesection
    	
    	? oActiveSection.caption
    	
    	sp_mainTable = oActiveSection.table
    	
    	? "sp_search_handler psTable" + sp_mainTable
    	local m_search
    	
    	? this.parent()
    	
    	m_search = dd_search_handler(sp_mainTable, sp_comboCondition, sp_combo, sp_textbox)		
    	lianja.get(sp_mainSection).sql = m_search
    	Lianja.getElementById(sp_mainSection).filter = ''
    		
    endproc
    In the search handler, is possible to refers to the combobox declared in AddSectionSearchPanel procedure?

    thanks
    Fabio

  2. #2
    Senior Member
    Join Date
    Jul 2013
    Location
    Ontario, Canada
    Posts
    658
    Hi Fabio,

    I'm not sure if this would be the same situation, although for my search panel, I created a public variables to match each item.
    Next, when defining the items for the search panel, I was associating them with the public variable.
    Once you have a public variable, you can create/associate any feature as though it were a control on a canvas section (such as valid or interactive change).

    Code:
    public sp_txtfind		// Search panel main text box.
    public sp_cboText		// Search panel combo box value.
    
    proc page1_section1_searchpanel()
      // Dynamically create the items in the search panel.
      sp_container = createObject("container")
    	
      // Determine the item to search for (combo box and textbox).
      sp_container.addObject("sp_cboSearch","combobox")
      sp_cboSearch.move(120,3,160,20)
      sp_cboSearch.addItems("Acct Number (XX######),Phone (##########),Last Name,Address")
      sp_cboSearch.interactivechange = sp_cboText_interactivechange
    	
      sp_cboSearch.listindex = -1
      if type("sp_cboListIndex") = "L"
        sp_cboListIndex = 0
      endif
      sp_cboSearch.listindex = sp_cboListIndex
      sp_cboText = sp_cboSearch
    
      sp_container.addObject("sp_txtsearch", "textbox")
      if type("sp_txtFind") <> "L"
        if len(sp_txtFind.text) > 0
          sp_txtsearch.text = sp_txtFind.text
        endif
      endif
      sp_txtsearch.returntabs = 1
      sp_txtsearch.valid = sp_txtFind_valid
      sp_txtFind = sp_txtsearch		// Save for public usage.
      sp_txtsearch.move(285, 3, 150, 20)	
    ...
    endproc
    
    proc sp_cboText_interactivechange()
      set_search_input_mask()
      sp_txtFind.text = ""
      sp_cboText.setFocus()
    endproc
    
    proc sp_txtFind_valid()
      lValidUsed = .F.
      sp_search_handler()
      lValidUsed = .T.
    endproc
    I hope this helps.

    With the code you provided, it appears as though you are doing something similar as I described with:
    sp_textbox = osp_textbox


    Cory

  3. #3
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,893
    Thank Cory, we are develop the same application? :-)
    thanks for the suggestion.

    the only doubt is about the use of public variables .. if I have multiple pages, could go in conflict .. or not?

    Fabio

  4. #4
    Senior Member
    Join Date
    Jul 2013
    Location
    Ontario, Canada
    Posts
    658
    It seems like we might have similar approaches for out application.

    As long as the public variable names are unique, I don't think there should be many issues using it over multiple pages.
    I haven't used it too much, although you can also use namesspaces to keep variables separate.

    Cory

  5. #5
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,161
    Blog Entries
    22
    In Lianja, objects and arrays are reference counted.

    You can create objects and add these objects as properties to the various Lianja UI elements such as a page or section. This provides you with the ability to extend the core UI elements.

    See the screenshot below. I opened the "lianjademo" app then fired up the App Inspector, then entered the commands that you see in the screenshot.

    So in fact you don't even need to use public variables, you can extend the UI elements with your own custom objects and as they are reference counted, they point at the same object so changing an object in one place changes it everywhere.

    Name:  Screen Shot 2015-02-21 at 10.59.09 AM.jpg
Views: 207
Size:  113.4 KB
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  6. #6
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,893
    OK, Barry, thank so much. I do noto know if I've understand all... But monday I try.. :-)

  7. #7
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,893
    Ok, I think I understand the concept.
    In this case, however, I add a container to SearchSection.
    How do I reference this object?
    I did a bit of testing, but without success ..

    Code:
    	sp_container = createObject("container")
    	sp_container.addObject("osp_combo", "Combobox")
    	sp_combo = osp_combo
    	osp_combo.move(5, 3, 80, 20)
    
    ..
    ..
    	this.addSearchPanel(sp_container)
    where this is the searchpanel.

    thanks for all the suggest.
    Fabio

  8. #8
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    I think that custom search panel is not intended to be fully "objected" in LOM. This panel is "rendering" stuff. After creating it, there is no possibility to acccess something like this:
    Code:
    page1.section1.sp_container.sp_textbox.caption="something new"
    You can do what you want in constructor but after that it is sealed and you depend on Lianja.showdocument(...)

    http://www.lianja.com/doc/index.php/SHOWDOCUMENT()

    e.g.
    Lianja.showDocument("page: page1.section1?action=search&text=keytosearchfor")
    Your arsenal is limited to:
    ?action=showsearchpanel
    ?action=hidesearchpanel
    ?action=togglesearchpanel
    You are out of luck. Nothing is exposed, I think.
    (maybe I am wrong).

  9. #9
    Lianja Team yvonne.milne's Avatar
    Join Date
    Feb 2012
    Location
    Berkshire, UK
    Posts
    1,840
    Hi Fabio,

    For example:

    Code:
    ////////////////////////////////////////////////////////////////
    // Event delegate for 'searchpanel' event
    proc Customers_section1_searchpanel()
    	sp_container = createObject("container")
    	sp_container.addObject("sp_label", "label")
    	sp_label.move(5, 3, 80, 20)
    	sp_label.text = "Company Name"
    	sp_container.addObject("osp_textbox", "textbox")
    	sp_textbox = osp_textbox
    	osp_textbox.move(85, 3, 100, 20)
    	sp_container.addObject("sp_search", "commandbutton")
    	sp_search.move(190, 3, 60, 20)
    	sp_search.text = "Search"
    	sp_search.click = sp_search_handler
    	sp_container.addObject("sp_clear", "commandbutton")
    	sp_clear.move(255, 3, 60, 20)
    	sp_clear.text = "Reset"
    	sp_clear.click = sp_reset_handler 
    	this.addSearchPanel(sp_container)
    	this.addProperty("SearchPanel",sp_container)  // Add reference to the object as a property
    endproc
    
    ////////////////////////////////////////////////////////////////
    // handlers for the Search Panel
    proc sp_search_handler()
    	Lianja.showDocument("section:section1?action=search&text="+sp_textbox.text)
    endproc
     
    proc sp_reset_handler()
    	Lianja.showDocument("section:section1?action=search&text=")
    	sp_textbox.text = ""
    endproc

    Now I can do this:

    Code:
    oSearchPanel = Lianja.get("Customers.section1").SearchPanel
    ? oSearchPanel.sp_label.text
    or this:

    Code:
    ? Lianja.get("Customers.section1").SearchPanel.sp_label.text
    Regards,

    Yvonne

  10. #10
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,893
    Hi Barry
    if I understand what you mean, I can associate an object to a section.

    I tried with:

    Code:
    	oActivePage = lianja.activepage
    	ActicePage = oActivePage.id
    	oActiveSection = Lianja.get(ActicePage).activesection		
    	sp_mainTable = oActiveSection.table
    
    	// add section property		
    	m_prop = oActiveSection.id + [.addProperty("searchTable", sp_mainTable)]
    	exec(m_prop)
    
    
    
    	sp_container.addObject("osp_comboCondition", "Combobox")
    	
    	// combo con gli operatori
    	sp_comboCondition = osp_comboCondition
    	osp_comboCondition.move(85, 1, 80, 20)		
    	osp_comboCondition.additem("Uguale")
    	osp_comboCondition.additem("Maggiore di")
    	osp_comboCondition.additem("Minore di")
    	osp_comboCondition.additem("Compreso")
    	osp_comboCondition.additem("Contenente")
    
    
    	// add section property	
    	m_prop = oActiveSection.id + [.addProperty("searchComboCondition", sp_comboCondition)]
    	exec(m_prop)
    but not work..

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us