Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Custom control on grid based on date field

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Custom control on grid based on date field

    I want one of my grids that has a transaction date field to show a different background color when the transaction date is 90 days and older from date().

    Below is my code as altered from the example applications but I evidently am not getting the proper code with the date fields.

    Code:
    on error goto TRANSDATE_xbasicError 							'do not delete this line
    
    'Write Xbasic code here that returns the HTML to be displayed by this control
    TRANSDATE_render = function QUANTITY_render as c (data as p, args as p, session as p)
    
    if data.TRANSDATE < "date()-90" then
    	TRANSDATE_render = <<%html%
    	<div style="color: #ffffff; text-align: center; background-color:#ffff00;font-weight:bold;">%html% + data.quantity + "</div>"
    else
    	if QUANTITY_render = <<%html%
    		<div style="color: #000000; text-align: center; background-color:#ffffff;font-weight:bold;">%html% + data.quantity + "</div>"
    	end if
    end if
    
    end  												'do not delete this line
    TRANSDATE_xbasicError: 										'do not delete this line
    TRANSDATE_render = "Error in custom control xbasic: " + error_text_get() 'do not delete this line
    end with 'do not delete this line
    end function 'do not delete this line

    #2
    This works for me:

    Code:
    Dim Current as D
    Dim Trained as D
    Current = now()
    Trained = data.Bbp_Date
    If ctod("")<> Trained then '....checks that data field is not empty
    	If 360 <= (Current - Trained) then
    		BBP_DATE_render = <<%html%
    		<div style="color:;text-align:center;background-color:Red;font-weight:bold;">%html% + data.Bbp_Date + "</div>"
    	else if 300 <= (Current - Trained) then
    		BBP_DATE_render = <<%html%
    		<div style="color:;text-align:center;background-color:Yellow;font-weight:bold;">%html% + data.Bbp_Date + "</div>"
    	else
    		BBP_DATE_render = <<%html%
    		<div style="color:;text-align:left;background-color:;font-weight:normal;">%html% + data.Bbp_Date + "</div>"
    	end if
    else
    	BBP_DATE_render = <<%html%
    	<div style="color:LightGrey;text-align:left;background-color:;font-weight:normal;">%html% + "No Entry" + "</div>"       '.... if empty then fills given text
    end if

    Comment


      #3
      This statement doesn't compute:
      Code:
      if data.TRANSDATE < "date()-90" then
      If data.TRANSDATE is a date value, you would not compare it to a string. If it is a character value, you would convert date()-90 to a character value using DTOC().

      Comment


        #4
        Thanks for the help. Below is the code I ended up with.

        Code:
        on error goto TRANSDATE_xbasicError 							'do not delete this line
        
        'Write Xbasic code here that returns the HTML to be displayed by this control
        dim current as D
        dim transactiondate as D
        current = date()-90
        transactiondate = data.transdate
        
        if transactiondate < current then
        	TRANSDATE_render = <<%html%
        	<div style="color: #ffffff; font-weight: bold; background-color: #ff0000; text-align: center;">%html% + data.transdate + "</div>"
        else
        	TRANSDATE_render = <<%html%
        		<div style="color: #000000; font-weight: normal; background-color: #ffffff; text-align: center;">%html% + data.transdate + "</div>"
        
        end if
        
        end  												'do not delete this line
        TRANSDATE_xbasicError: 										'do not delete this line
        TRANSDATE_render = "Error in custom control xbasic: " + error_text_get() 'do not delete this line
        end with 'do not delete this line
        end function 'do not delete this line

        Comment


          #5
          I thought that this was going to work for me but I get the following error when I try to enter a new record by clicking on "new record" from my grid.

          Code:
          500 Internal Server Error
          Script Error
          Error:Script: /aml/bookbrowse.a5w line:22
          x_BookkeepingBrow = a5w_run_Component(tmpl_BookkeepingBrow)
          Property not found
          dataArr.array subelement not found.
          
          Alpha Five/7.0 Build/3960-3018 at tsserver1 Port 81

          Comment


            #6
            Actually for the math to work he has to convert data.TRANSDATE from character to date as in CTOD(data.TRANSDATE) or am I wrong.

            CHuck

            Originally posted by Edward Larrabee
            This statement doesn't compute:
            Code:
            if data.TRANSDATE < "date()-90" then
            If data.TRANSDATE is a date value, you would not compare it to a string. If it is a character value, you would convert date()-90 to a character value using DTOC().

            Comment


              #7
              I may be totally wrong but I think in this case you are assigining a variable that you defined as a Date type [transactiondate] to the [data.transdate] object which is a character type. I think you need to make the conversion in your assignment.
              transactiondate = ctod(data.transdate).

              I don't no if this is causing the WAS error. The cryptic WAS errors leave little to be desired in terms of helpful information to me.

              CHuck

              Originally posted by George Corder
              Thanks for the help. Below is the code I ended up with.

              Code:
              on error goto TRANSDATE_xbasicError 							'do not delete this line
              
              'Write Xbasic code here that returns the HTML to be displayed by this control
              dim current as D
              dim transactiondate as D
              current = date()-90
              transactiondate = data.transdate
              
              if transactiondate < current then
              	TRANSDATE_render = <<%html%
              	<div style="color: #ffffff; font-weight: bold; background-color: #ff0000; text-align: center;">%html% + data.transdate + "</div>"
              else
              	TRANSDATE_render = <<%html%
              		<div style="color: #000000; font-weight: normal; background-color: #ffffff; text-align: center;">%html% + data.transdate + "</div>"
              
              end if
              
              end  												'do not delete this line
              TRANSDATE_xbasicError: 										'do not delete this line
              TRANSDATE_render = "Error in custom control xbasic: " + error_text_get() 'do not delete this line
              end with 'do not delete this line
              end function 'do not delete this line

              Comment


                #8
                I am getting the output that I am seeking while viewing the grid, it is just that when a user tries to add a new record that they get this error.

                Comment


                  #9
                  I am still getting an error on this when trying to add a new record. The grid displays correctly while just browsing the data as shown in the thumbnail. If I can get a proper grid display, why do I get the following error when trying to add a new record? It has to be in my 'Character' or 'Date' type properties I suspect but I can't get this straight.

                  500 Internal Server Error
                  Script Error
                  Error:Script: /LivePreview/BookkeepingBrowse_LivePreview.a5w line:21
                  x_out = a5w_run_Component(tmpl)
                  Property not found
                  dataArr.array subelement not found.


                  --------------------------------------------------------------------------------

                  Alpha Five/7.0 Build/3960-3018

                  CODE IN USE:

                  Code:
                  function TRANSDATE_render as c (data as p, args as p, PageVars as p) 'do not delete this line
                  with PageVars	'do not delete this line
                  'Specify the Xbasic that returns the HTML for this control. 
                  'This function must return TRANSDATE_render, which should
                  'contain the HTML that will be displayed.
                  'The 'data' argument that is passed in contains the current 
                  'row value for each of the fields in the Grid. For example
                  'if the Grid displays the customerid, firstname and lastname
                  'fields, you can reference the values in these fields as
                  'data.customerid, data.firstname and data.lastname
                  
                  '-------------------------------------------------------------------
                  on error goto TRANSDATE_xbasicError 							'do not delete this line
                  
                  'Write Xbasic code here that returns the HTML to be displayed by this control
                  dim current as D
                  dim transactiondate as D
                  currentd = date()-9
                  transactiondate = Data.TRANSDATE
                  
                  if transactiondate < currentd then
                  	TRANSDATE_render = <<%html%
                  	<div style="color: #ff0000; font-weight: normal; background-color: #ffffff; text-align: center;">%html% + data.transdate + "</div>"
                  else
                  	TRANSDATE_render = <<%html%
                  		<div style="color: #000000; font-weight: normal; background-color: #ffffff; text-align: center;">%html% + data.transdate + "</div>"
                  
                  end if
                  
                  end  												'do not delete this line
                  TRANSDATE_xbasicError: 										'do not delete this line
                  TRANSDATE_render = "Error in custom control xbasic: " + error_text_get() 'do not delete this line
                  end with 'do not delete this line
                  end function 'do not delete this line

                  Comment


                    #10
                    Getting the same error

                    I am getting the same error, but don't think it has anything to do with data types.

                    Using an ADO data source I created a tabular read only grid with an updateable detail view and no search part.

                    I added two fields to the grid, one a key recordID field to use as the DetailView link, and a second character DataField, for which I set Control Type = Custom. I added the DataField to the detail view. The only Detail View Properties I changed from default was to "Only show Detail View on request" and to "Hide Grid part when Detail View is visible".

                    Either with publishing or via Live Preview the click on recordID field to update/delete works ok. But when you click on New Record to add, the following error appears:

                    500 Internal Server Error
                    Script Error
                    Error:Script: /LivePreview/test1_LivePreview.a5w line:219
                    x_out = a5w_run_Component(tmpl)
                    Property not found
                    dataArr.array subelement not found.

                    If you change the grid Control Type to Label for the DataField the error goes away and the component works correctly. It doesn't appear to matter or not whether there is HTML code inserted in the Custom Control Property Definition. Either leaving the Definition with the default prompt or copying in a code segment from the "Creating a Custom Grid Control" help file page doesn't modify the error behavior. The custom code works on the grid, but defining the custom control hangs the Detail View New Record procedure. I couldn't find any reference to "dataArr.array" so tracking that down hasn't been helpful.

                    Need help on this one.

                    Comment


                      #11
                      You cannot use custom controls for data entry. See Creating a Custom Grid Control.

                      Comment


                        #12
                        Ed, my grid is set so that if I click on the "New Record" link at the top and bottom of my grid, the user is taken to a detail record page to input their data. This detail grid should not have the coustom control on it. Does the custome control carry over from the grid to the detail page unless you design a seperate entry page form?
                        Last edited by George Corder; 03-27-2006, 05:31 PM.

                        Comment


                          #13
                          I would ask the same question as George.
                          The help message says "Custom controls cannot be used for data entry to bound table fields". The custom control is in a non-editable grid field from which data entry is not possible. There is no custom control in the Detail View. It appears that fields in grid and detail view each are bound separately. And, why does update/delete work but add does not?

                          Comment


                            #14
                            Dale, have you gotten further on this?

                            Comment


                              #15
                              George,
                              Not much. I am using custom controls but only in a read-only grid. For data entry I have used one of the columns as a link field to a different page where I present a dialog or an editable grid without custom controls.

                              Comment

                              Working...
                              X