Alpha Video Training
Results 1 to 2 of 2

Thread: Why does this javascript IF test for an empy string not work ?

  1. #1
    Member
    Real Name
    mike weatherley
    Join Date
    Jan 2011
    Posts
    33

    Default Why does this javascript IF test for an empy string not work ?

    I'm trying to test if a column of data in a grid is empty then not display the column.
    I'm using this code in the afterSearchSubmit javascript event

    Code:
    // Set the variables
    var showcolumn=false;
    var ele='';
    
    
    // Check for any data in search results for the column
    for (var i=1; i<={grid.object}._rowsInGrid; i++) {
    	ele = $('{grid.componentName}.V.R'+i+'.COL1');
    	if ($gvs(ele)!='') {
    	showcolumn=true;
    	break;	
    	}
    }
    
    // Show or Hide the Column
    if (!showcolumn) {
    	{grid.object}.showGridColumn('COL1',false);
    	}
    	else {
    	{grid.object}.showGridColumn('COL1',true);
    	}
    The column is not being hidden even if there is no data for this column ?

  2. #2
    Member
    Real Name
    mike weatherley
    Join Date
    Jan 2011
    Posts
    33

    Default Re: Why does this javascript IF test for an empy string not work ?

    Figured it out
    The field is formatted for currency and even though there is no data in the field Alpha formats the html with a non breaking space (&nbsp;).
    Changing the if statement to,

    if ($gvs(ele)!='&nbsp;') {
    showcolumn=true;
    break;
    }

    fixes the problem.

Similar Threads

  1. Action JavaScript not available in Grid Javascript function declarations
    By Clipper87 in forum Application Server Version 10 - Web/Browser Applications
    Replies: 1
    Last Post: 09-23-2010, 10:22 AM
  2. Mixing javascript and Xbasic and other javascript questions ...
    By drgarytraub in forum Application Server Version 9 - Web/Browser Applications
    Replies: 4
    Last Post: 07-08-2008, 06:15 PM
  3. test
    By narendra in forum Announcements
    Replies: 0
    Last Post: 11-23-2001, 10:51 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
  •