javascript - Passing values between view and controller query in grails -
i have grails controller(tablev1classcontroller.groovy) sql query looks like:
class tablev1classcontroller { def datasource def listjson = { def sql = new sql(datasource) def rows = sql.rows("select date_hour, total_revenue sales, visits, marketing, organic, single_page_visits , total_units tablev1 si_flag ='serialized' ") sql.close() render rows json } }
in views,i have dropdown following:
<select id="si_flag" class="wrapper-dropdown"> <option value ="serialized">serialized</option> <option value ="non-serialized">non-serialized</option> </select> var si_flag = document.getelementbyid('si_flag');
how can value stored in variable 'si_flag' passed parameter query defined in controller(in condition).
nisha
first thing have make sure varible si_flag
posted controller , since can't see post or ajax call in code.
then , re-write query follows :
def rows = sql.rows("""select date_hour, total_revenue sales, visits, marketing,organic, single_page_visits , total_units tablev1 where"""+params?.si_flag""+""" ='serialized' """)
then works !! make sure si_flag having value when posted controller. can use
log.info(""content of si_flag posted"+parmas.si_flag) or pritnln "content of si_flag posted :$params.si_flag"
Comments
Post a Comment