Alpha Video Training
Results 1 to 12 of 12

Thread: Using a checkbox on a grid

  1. #1
    Member
    Real Name
    Lee Cook
    Join Date
    Mar 2010
    Posts
    217

    Default Using a checkbox on a grid

    I'm going to use the grid checkbox to create a where statement for mysql since I need to perform several operations on the checked rows.

    Problem is that I can't find any videos or anything else that shows how to cycle through the grid rows and perform an action on the checked rows.

    example:
    for i = 1 to (number of rows)
    if (row is checked(i)) then (add id to sql where statement)
    next

    any ideas on this or links to videos?

  2. #2
    Alpha Software Employee Selwyn Rabins's Avatar
    Real Name
    Selwyn Rabins
    Join Date
    Mar 2000
    Location
    Boston, MA
    Posts
    5,306

    Default Re: Using a checkbox on a grid

    Quote Originally Posted by leec2000 View Post
    I'm going to use the grid checkbox to create a where statement for mysql since I need to perform several operations on the checked rows.

    Problem is that I can't find any videos or anything else that shows how to cycle through the grid rows and perform an action on the checked rows.

    example:
    for i = 1 to (number of rows)
    if (row is checked(i)) then (add id to sql where statement)
    next

    any ideas on this or links to videos?
    i just created a video.
    see number 87

    http://news.alphasoftware.com/V10Preview/videos.htm

  3. #3
    "Certified" Alphaholic mmaisterrena's Avatar
    Real Name
    Mauricio Maisterrena
    Join Date
    Nov 2006
    Location
    Torreon, Mexico
    Posts
    1,435

    Default Re: Using a checkbox on a grid

    check this threat I posed some useful code there http://msgboard.alphasoftware.com/al...light=checkbox
    Cheers
    Mauricio


  4. #4
    Member
    Real Name
    Lee Cook
    Join Date
    Mar 2010
    Posts
    217

    Default Re: Using a checkbox on a grid

    Thank you Selwyn for the video.

    The last thing I need to do is activate a button on the grid when it regenerates after the show checked button is clicked. Since the show/hide expression is javascript, I can't seem to set a variable to activate the button since all the code I've written is xbasic.

    any ideas?

  5. #5
    Alpha Software Employee Selwyn Rabins's Avatar
    Real Name
    Selwyn Rabins
    Join Date
    Mar 2000
    Location
    Boston, MA
    Posts
    5,306

    Default Re: Using a checkbox on a grid

    Quote Originally Posted by leec2000 View Post
    Thank you Selwyn for the video.

    The last thing I need to do is activate a button on the grid when it regenerates after the show checked button is clicked. Since the show/hide expression is javascript, I can't seem to set a variable to activate the button since all the code I've written is xbasic.

    any ideas?
    i don't understand the question.

    if you are writing xbasic, then i assume you have a function that is handling an ajax callback?
    if so, the xbasic function generates javascript which it sends back to the browser. this javascript can include the code to set focus to any control on the page.

  6. #6
    Member
    Real Name
    Lee Cook
    Join Date
    Mar 2010
    Posts
    217

    Default Re: Using a checkbox on a grid

    It's probably very simple to do. At the end of the function is this:

    dim cmd as c
    cmd = "{grid.object}.gridFilterSet('" + js_escape(filter) + "');"
    showChecked = cmd


    Is there a way to use this to send multiple lines of javascript like this:

    dim cmd as c
    cmd = "{grid.object}.gridFilterSet('" + js_escape(filter) + "');" + crlf()
    + "var showbutton = 1;"
    showChecked = cmd


    This was my first attempt but I couldn't find out how to do it.

  7. #7
    Alpha Software Employee Selwyn Rabins's Avatar
    Real Name
    Selwyn Rabins
    Join Date
    Mar 2000
    Location
    Boston, MA
    Posts
    5,306

    Default Re: Using a checkbox on a grid

    Quote Originally Posted by leec2000 View Post
    It's probably very simple to do. At the end of the function is this:

    dim cmd as c
    cmd = "{grid.object}.gridFilterSet('" + js_escape(filter) + "');"
    showChecked = cmd


    Is there a way to use this to send multiple lines of javascript like this:

    dim cmd as c
    cmd = "{grid.object}.gridFilterSet('" + js_escape(filter) + "');" + crlf()
    + "var showbutton = 1;"
    showChecked = cmd


    This was my first attempt but I couldn't find out how to do it.
    you are sending back a string that contains javascript code.

    this string can contain as many lines of javascript code as you want. it could contain thousands of lines of javascript if you wanted. there is no limit to the complexity of the javascript that you return.

    so, for example, you could do this in your xbasic:

    dim cmd as c = ""
    cmd = cmd + "alert('message 1');"
    cmd = cmd + "alert('message 2');"
    cmd = cmd + "var x = 1;"
    cmd = cmd + "var y = 2;"
    cmd = cmd + " var z = x + y; alert(z); "

  8. #8
    "Certified" Alphaholic mmaisterrena's Avatar
    Real Name
    Mauricio Maisterrena
    Join Date
    Nov 2006
    Location
    Torreon, Mexico
    Posts
    1,435

    Default Re: Using a checkbox on a grid

    Or

    Code:
    dim cmd as c = ""
    
    cmd = <<%str% 
    alert('message 1');
    alert('message 2');
    var x = 1;
    var y = 2;
    var z = x + y; alert(z); 
    %str%
    or this other example of a long JScode

    Code:
    FUNCTION Fn_Reporte_Generar as c (e as p)
    	
    			Reporte = e._currentRowDataNew.char2
    			Nombre = e._currentRowDataNew.char4
    			Filtro_RepActi = e._currentRowDataNew.char3
    			Filtro_RepActi = strtran(Filtro_RepActi,"W"," ")
    			Filtro_RepActi = strtran(Filtro_RepActi,"Z","=")
    			
    			Fn_Reporte_Generar = <<%str%
    			$('Reporte').innerHTML = '<div style=\'cursor:pointer;\' onclick=\'hideFrameDiv__Unbound_Button_1_2_GridFields(); return false;\'><a5:r>Cerrar</a5:r></div><iframe style=\'height: 600px; width: 800px;\'  id=\'IFRAME_Reporte\' src=\'__workingMessage.a5w?message=<a5:r>Generando_Reporte</a5:r>&icon=CSS/A5System/images/wait.gif\'></iframe>'; showFrameDiv__Unbound_Button_1_2_GridFields();
    			//var tbiObjTemp = getTabbedUI();
    			var ro = new Object();
    			ro.reportName = '%str% + Reporte + <<%str%
    			';
    			ro.reportNameShort = '%str% + Nombre + <<%str%
    			';
    			ro.reportType = 'Report';
    			ro.reportIFrame = 'IFRAME_Reporte';
    			ro.filter = '';
    			ro.order = '';
    			ro.sqlFilter = '%str% + Filtro_RepActi + <<%str%
    			';
    			ro.sqlOrder = '';
    			ro.arguments = '';
    			ro.workingMessage = '<a5:r>Generando_Reporte</a5:r>'
    			ro.pdfoptions = 'DIM Concatenate as L\nDIM HasWatermark as L\nDIM MultilingualSupport as L = .T.\nDIM EmbedFonts as L = .T.\nDIM LinearizeForWeb as L\nDIM Colors2GrayScale as L\nDIM ConvertHyperlinks as L = .T.\nDIM WatermarkType as C = `Text`\nDIM WatermarkText as C = `D R A F T`\nDIM WatermarkFontName as C = `Times New Roman`\nDIM WatermarkFontSize as N = 172\nDIM WatermarkRotation as N = 450\nDIM WatermarkColorHex as C = `E8FED2`\nDIM WatermarkHorizPos as N = 120\nDIM WatermarkVertPos as N = -120\nDIM WatermarkOnTop as L\nDIM WatermarkPDF as C\nDIM Encrypt as L\nDIM OwnerPassword as C\nDIM UserPassword as C\nDIM CanPrint as L = .T.\nDIM CanModifyDocument as L = .T.\nDIM CanCopy as L = .T.\nDIM CanAddNotes as L = .T.\nDIM Use128BitKey as L = .T.\nDIM JpegQuality as C = `Medium`\n';
    			ro.displayMode = '';
    			ro.saveAs = 'pdf';
    			ro._gridCurrentFilter = '';
    			ro._gridCurrentOrder = '';
    			ro._gridCurrentArguments = '';
    			ro._gridCurrentDBType = 'sql';
    		
    			A5.component.runReport(ro);
    			%str%
    			'Fn_Reporte_Generar = "alert('"+Reporte+"');"
    	
    END FUNCTION
    Last edited by mmaisterrena; 09-22-2010 at 02:49 AM.
    Cheers
    Mauricio


  9. #9
    Member
    Real Name
    Lee Cook
    Join Date
    Mar 2010
    Posts
    217

    Default Re: Using a checkbox on a grid

    I sure appreciate all the help guys but I'm still stuck on this so I want to exlain the objective .

    If you look at the attachment you will see three action buttons on the bottom. What I need to do is show the first button(Show Checked) by itself when the grid is opened.

    After the user checks some boxes and presses the first button the grid regenerates showing only checked rows. At this point, only the second button(Print Audit Report) should appear.

    After the report is printed only the third button(Finish) should appear.

    In short there should never be more than 1 button on the bottom of the grid.

    My first thought was just to make it a training issue but the title companies that use this hire a lot of temps and so training must be minimal.

    I've been trying to use show hide variables but when the grid regenerates they are all reset.

    I realize that my lack of experience with A5 is showing and that the solution is simple but I've spent all week trying to do this and everything I've tried so far hasn't worked.

    Any ideas will be appreciated.

  10. #10
    Member
    Real Name
    Norman Lok
    Join Date
    Mar 2010
    Posts
    28

    Default Re: Using a checkbox on a grid

    To show/hide button, the following script may help:

    Code:
    document.getElementById('button1').style.display = 'none';
    document.getElementById('button1').style.display = 'block';
    document.getElementById('button1').style.visibility = 'visible';
    document.getElementById('button1').style.visibility = 'hidden';

    The returning javascript of Button1 need to do 3 things
    1) filter the grid
    2) hide itself
    3) show Button2

    Same for returning javascript of Button2
    1) Print report
    2) hide itself
    3) show Button3


    Code Snippet of xb_button1:
    Code:
    function xb_button1 ()
    ...
    dim cmd as c
    cmd = "{grid.object}.gridFilterSet('" + js_escape(filter) + "');" 
    cmd = cmd  + "document.getElementById('button1').style.visibility = 'hidden';
     "
    cmd = cmd  + "document.getElementById('button2').style.visibility = 'visible';
     "
    xb_button1 = cmd
    Norman

  11. #11
    Member
    Real Name
    Norman Lok
    Join Date
    Mar 2010
    Posts
    28

    Default Re: Using a checkbox on a grid

    Can I show a dialog box like javascript prompt() to let user enter a message and then call the xb function to store the input message into checked rows?

    For instance.
    Table field: id, firstname, lastname, salutation.
    Content
    1, Norman, Lok , null
    2, Selwyn, Rabin, null
    3, Janet, Cook, null
    etc..

    User click checkbox of row 1 and 2
    Click a button, popup a dialog box.
    User enter [Mr.] (Better to lookup from database table "salute ")
    click submit button.
    The xb side will replace [saluation] of row 1,2 with [Mr. Norman Lok] and [Mr. Selwyn Rabin]

    User click checkbox of row 3
    Click a button, popup a dialog box.
    User enter [Miss]
    click submit button.
    The xb side will replace [saluation] of row 3 with [Miss Janet Cook].

    The final table would look like:
    1, Norman, Lok, Mr. Norman Lok
    2, Selwyn, Rabin, Mr. Selwyn Rabin
    3, Janet, Cook, Miss Janet Cook

    I've using javascript prompt() function to gather user input but it lacks lookup function.

    So, I build a grid component (enter record form) with lookup.
    When I use action script to popup the grid component, I don't know how to gather user input inside the popup grid component.

    Is there any other better method?
    Norman

  12. #12
    Member
    Real Name
    Lee Cook
    Join Date
    Mar 2010
    Posts
    217

    Default Re: Using a checkbox on a grid

    Thanks you so much for this. One of the things I've struggled with is going back and forth between xbasic and javascript. This has opened a lot doors for me. Looks like next week will be loads of fun trying all this stuff out.

Similar Threads

  1. Checkbox in Grid over MySQL
    By lgrupido in forum Application Server Version 10 - Web/Browser Applications
    Replies: 1
    Last Post: 06-18-2010, 04:31 PM
  2. Checkbox on Grid
    By njguy in forum Application Server Version 10 - Web/Browser Applications
    Replies: 7
    Last Post: 06-15-2010, 10:02 AM
  3. weird checkbox issue in grid
    By mikew in forum Application Server Version 9 - Web/Browser Applications
    Replies: 0
    Last Post: 02-23-2009, 09:30 PM
  4. Grid Checkbox in search does not work
    By mikew in forum Application Server Version 9 - Web/Browser Applications
    Replies: 1
    Last Post: 11-29-2008, 03:55 PM
  5. Center Checkbox in Grid
    By Peter.Greulich in forum Application Server Version 8
    Replies: 3
    Last Post: 10-09-2007, 06:07 PM

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
  •