0
<body>
<hr>
<h1>Click All or Search by Core ID</h1>
<form action = "call.jsp" onsubmit="return generateReport()" >
<label><input type="checkbox" /> ALL</label><p>Core ID : <input type= "text" name = "core" value = ""/></p>
<h1>Search by refresh Date From and To</h1>
<p>Date From: <input type="text" id="datepicker" name = "datef" value = ""></p>
<p>Date To  : <input type="text" id="datepicker1" name = "datet" value = ""></p>
<h1>All Department except</h1>
<p>Department Code : <input type="text" name = "DepartM" value = ""></p>
<input type="submit" value="Search"/>
</form>
</body>

Above are the code for jsp and I want the checkbox once click it will select all id and date from and to and below are my jasper report query

 SELECT
 CI_ID,
 Status,
 "status-Reason",
 CI_name,
 Serial_num,
 Manufacturer,
 model,
 receipT_date,
 refresh,
 core_id,
 departm
FROM
 `laptop` laptop
WHERE
 Core_id = $P{core}
 or refresh >= $P{datef}
 and refresh <= $P{datet}
 and departm <> $P{DepartM}

How can I use the checkbox as the select all function? Meaning to say once the user click the checkbox mean the user want to view all record (all id and from and to date etc).

Shaw
  • 41
  • 9
  • let say my database got 10 id with date range from 01-01-2014 to 01-01-2017 and my current page can let user select which id and date from and to only, now Im trying to do a select "all" checkbox so that the user no need to fill in the date , the user just click on the checkbox and the page able to pass all the parameter(from 01-01-2014 to 01-01-2017 and select all 10 id) in the jasper report. – Shaw Apr 14 '16 at 01:09

1 Answers1

0

Jasper report dynamic query will help you to solve your issue.

<parameter name="STATUS"/><br />
<parameter name="whereClause" isForPrompting="false"><br />
  <defaultValueExpression><br />
    $P{STATUS}.equals("ALL"«») ? "" : (" WHERE status = '" + $P{STATUS} + "'"«»)<br />
  </defaultValueExpression><br />
</parameter><br />
<queryString><br />
  SELECT .. FROM .. $P!{whereClause}<br />
</queryString><br />
</td></tr></tbody></table><br />
<br />

Refer link http://community.jaspersoft.com/questions/514371/how-construct-dynamic-query-reports

http://community.jaspersoft.com/blog/how-write-conditional-query-ireport-using-parameters

balamuruganv
  • 123
  • 6
  • $P!{, that is not the best way, you should use prepared statement $P{, to avoid sql injection code, see this post http://stackoverflow.com/questions/11871042/jasperreports-passing-parameters-to-query – Petter Friberg Apr 13 '16 at 16:53