Zomar
|
| Posted: 11/18/2004, 1:56 AM |
|
I would like to have a way to display in the grid only tasks with a NULL {task_finish_date}. Another words pending tasks. Preferably in the search bar. Can this be done with a checkbox/radio button Any suggestions?
|
|
|
 |
mrachow
Posts: 509
|
| Posted: 11/18/2004, 4:25 AM |
|
I'm not sure if I got the problem right.
If you say in Where for the grid
task_fish_date IS NULL
the grid should show all these records?!
Regards,
Michael
_________________
Best regards,
Michael |
 |
 |
dataobjx
Posts: 181
|
| Posted: 11/18/2004, 5:10 AM |
|
STEP 1.
Add a check box to your search box. Give the search box the name: chk_pending
STEP 2.
Select the grid. From the events toolbox, select the "Before Build Select" event and perform a right click - "Add Code..."
STEP 3.
Add the code located in the example below into the grids BeforeBuildSelect() event.
Modify the code replacing the "YourGridDataSourceName" with the name of your grid.
STEP 4.
Add the "Supporting Functions Begin ==>...to... Supporting Functions End" code block to the bottom of the _events page for the grid.
STEP 5.
TEST. Un-rem the statements in the BeforeBuildSelect() function and view the results.
When all is working as anticipated remove the remarks or rem them out again.
ALTERNATIVES
You could also use a list box. However, there are times where - if a list box is only going to hold 2 values... its hardly worth using and in such cases a check box or set of radio buttons provides a better interface.
Function YourGridDataSourceName_DataSource_BeforeBuildSelect()
Dim CHK
Dim sSQLWhere
sSQLWhere = YourGridDataSourceName.datasource.where
CHK = getCheckBoxValue(GetParam("chk_pending"), "1", "0", "Integer")
'Response.Write "YourGridDataSourceName.datasource.where: '" & sSQLWhere & "'<HR>"
'Response.Write "CHK: " & CHK & "<HR>"
'response.end
If CHK = 1 Then
If sSQLWhere = EMPTY Then
sSQLWhere = " task_finish_date IS NULL"
Else
sSQLWhere = SQLWhere & " AND task_finish_date IS NULL"
End If
Else
If sSQLWhere = EMPTY Then
sSQLWhere = " task_finish_date IS NOT NULL"
Else
sSQLWhere = SQLWhere & " AND task_finish_date IS NOT NULL"
End If
End If
'Response.write "SQLWhere: " & sSQLWhere & "<BR>"
YourGridDataSourceName.datasource.where = sSQLWhere
End Function
'Supporting Functions Begin ********************************************************
Function getCheckBoxValue(sVal, CheckedValue, UnCheckedValue, sType)
If isempty(sVal) Then
If UnCheckedValue = "" Then
getCheckBoxValue = "Null"
Else
If sType = "Number" Or sType = "Integer" Then
getCheckBoxValue = UnCheckedValue
Else
getCheckBoxValue = "'" & Replace(UnCheckedValue, "'", "''") & "'"
End If
End If
Else
If CheckedValue = "" Then
getCheckBoxValue = "Null"
Else
If sType = "Number" Or sType = "Integer" Then
getCheckBoxValue = CheckedValue
Else
getCheckBoxValue = "'" & Replace(CheckedValue, "'", "''") & "'"
End If
End If
End If
End Function
Function GetParam(ParamName)
Dim Param
If Request.QueryString(ParamName).Count > 0 Then
Param = Request.QueryString(ParamName)
ElseIf Request.Form(ParamName).Count > 0 Then
Param = Request.Form(ParamName)
Else
Param = ""
End If
If Param = "" Then
GetParam = Empty
Else
GetParam = Param
End If
End Function
'Supporting Functions End ********************************************************
_________________
www.DataObjx.net
www.mydigitalapps.com |
 |
 |
Zomar
|
| Posted: 11/18/2004, 10:54 PM |
|
This looks great I must be doing something wrong cause I get this error:
Parse error: parse error, unexpected T_STRING, expecting '{' in /home/virtual/site46/fst/var/www/taskman/TaskList2_events.php on line 12
My line 12 is: Dim CHK
|
|
|
 |
dataobjx
Posts: 181
|
| Posted: 11/19/2004, 6:17 AM |
|
This post was located in the "General" location and you never specified your language... but it appears from your final post that you're using PHP.
The code above is .ASP... so you'll need to translate it to PHP accordingly... however the logic should remain the same.
I think I derived the two (2) supporting function from common.asp or one of the other standard "Common Files".... so there is likely a PHP replacement that you can find for both of the supporting functions.
Hope this guides you in the right direction.
_________________
www.DataObjx.net
www.mydigitalapps.com |
 |
 |
Zomar
|
| Posted: 11/19/2004, 3:05 PM |
|
I am feeling quite foolish that I didn't specify that I was using php especially after all the effort you put in. I am a beginner and will let you know how I make out with the conversion. Thanks so much!!
|
|
|
 |
Zomar
|
| Posted: 11/20/2004, 2:02 PM |
|
Here's where I am at but still having problems:
function tasks_DataSource_BeforeBuildSelect() {
//dim $CHK;
//dim $sSQLWhere;
$sSQLWhere = tasks.$datasource.$where;
$CHK = $getCheckBoxValue[$GetParam["chk_pending"], "1", "0", "Integer"];
//Response.Write "tasks.datasource.where: '" & sSQLWhere & "'<HR>"
//Response.Write "CHK: " & CHK & "<HR>"
//response.end
if ($CHK == 1) {
if ($sSQLWhere == EMPTY) {
$sSQLWhere = " task_finish_date IS NULL";
} else {
$sSQLWhere = $SQLWhere." AND task_finish_date IS NULL";
}
} else {
if ($sSQLWhere == EMPTY) {
$sSQLWhere = " task_finish_date IS NOT NULL";
} else {
$sSQLWhere = $SQLWhere." AND task_finish_date IS NOT NULL";
}
}
//Response.write "SQLWhere: " & sSQLWhere & "<BR>"
tasks.$datasource.$where = $sSQLWhere;
}
//Supporting Functions Begin ********************************************************
function $getCheckBoxValue[$sVal, $CheckedValue, $UnCheckedValue, $sType] {
if (isempty($sVal)) {
if ($UnCheckedValue == "") {
$return "Null";
} else {
if ($sType == "Number" || $sType == "Integer") {
$return $UnCheckedValue;
} else {
$return "'".Replace($UnCheckedValue, "'", "''")."'";
}
}
} else {
if ($CheckedValue == "") {
$return "Null";
} else {
if ($sType == "Number" || $sType == "Integer") {
$return $CheckedValue;
} else {
$return "'".Replace($CheckedValue, "'", "''")."'";
}
}
}
}
function $GetParam[$ParamName] {
//dim $Param;
if (@$_GET[$ParamName].$Count > 0) {
$Param = @$_GET[$ParamName];
} elseif (@$_POST[$ParamName].$Count > 0) {
$Param = @$_POST[$ParamName];
} else {
$Param = "";
}
if ($Param == "") {
$return Empty;
} else {
$return $Param;
}
}
//Supporting Functions End ********************************************************
|
|
|
 |
|