0

I am building a grails application for large datasets and facing various problems due to loading a large json file on the javascript side (client side) of my application, due to which the browser crashes.

Now, I have realized I am taking all user selections on the javascript side only, but I'm assuming it can be done on the grails controller side also using the tag and "params"

I am looking at :

http://grails.org/doc/latest/ref/Tags/link.html
http://grails.org/doc/latest/ref/Tags/form.html

But, I'm very new to this and needed some direction if what I'm trying to do is feasible or not? Basically, I want the user to select a bunch of dropdowns, the values of which are passed to my grails controller and the controller sends the filtered data to the javascript to load, such that only the relevant data is sent to the browser and it runs properly.

UPDATE

package marchmock2
class Tablev1class {
Date date_hour
String mv
String pagetype
Integer visits
Integer visits_ly
Integer visits_lw
String time_period
String platform
String device
String browser


static mapping = {
table "pgtyp"
version false        
date_hour column: "date_hour"
mv column: "mv"
pagetype column: "pagetype"
visits column: "visits"
visits_ly column:"visits_ly"
visits_lw column:"visits_lw"
time_period column:"time_period"
platform column:"platform"
device column:"device"
browser column:"browser"
}
static constraints = {
}
}

This is how my domain class looks like and there is no dependency. All I want is create selects from various mv, pagetype, platform, device, browser and make the selections made pass to the controller which has a query to be made to the database

Nisha
  • 199
  • 1
  • 3
  • 18
  • Create g:select elements that list the same table set optionValue to be different objects I.e. first selwct optionValue mv 2nd pagetype and so on. If you need it to calc something as user selects then look at onchange and a remotecall on it to xall controller that processes selected element – V H Jul 03 '14 at 07:53

1 Answers1

0

I think you may need to edit question and redefine your requirements in the the last section.

You could take a look here:

I want my selects dropdowns to auto populate with Ajax in Grails website

On this question I sort of broke up how you can use remote calls to collect data from one field to generate the next selection ? is this part of the requirements or are these all single selections that have no dependencies on each other ?

If dependency related selection then take at ajaxdependancyselection plugin where proper nested selections can be achieved.If selection is from large data set then maybe advice on primary question would probably be quicker.....

UPDATE Since they are independent, You could load up the

<g:select name="input1" from="${domainClass1.list()}" ...>

for each domainClass call Post it back to your controller

In your controller

def d1=domainClass1.get(params.input1)
def d2=domainClass2.get(params.input2)

render (view: 'something', model: [ d1: d1, d2:d2 ] )

and so on then you could expand on each of the domainClass objects passed and get specific related elements out of each d1 d2 etc....

I am really unsure of objective so apologies if it is not what your looking for

UPDATE UPDATE

Unsure why you need to have selections per object, maybe as you say you want to then do something with the values.. In which case look at the last example the optionKey and optionValue are all set to device so it will show device in the selection and user selection will end up being actual device selection

<g:select id="mv" name="mvid" from="${marchmock2.Tablev1class.list()}" optionKey="id"   optionKey="mv" required="" value="${params?.mvid}" class="many-to-one"/>
<g:select id="mv" name="mvid" from="${marchmock2.Tablev1class.list()}" optionKey="id"   optionKey="pagetype" required="" value="${params?.mvid}" class="many-to-one"/>

<g:select id="mv" name="mvid" from="${marchmock2.Tablev1class.list()}" optionKey="id"   optionKey="platform" required="" value="${params?.mvid}" class="many-to-one"/>

<g:select id="mv" name="mvid" from="${marchmock2.Tablev1class.list()}" optionKey="device"   optionKey="device" required="" value="${params?.mvid}" class="many-to-one"/>

Now to expand this

<g:select id="mv" name="mvid" from="${marchmock2.Tablev1class.list()}" optionKey="device"   optionKey="device" required="" value="${params?.mvid}" class="many-to-one" onchange="${remoteFunction (
        controller: 'someController',
        action: 'someAction',
        params: "'device=' + this.value",
        update: 'newDivId'
    )}"/>

<div id="newDivId">
<!-- your output from when user selects something from above will end up showing the result from the someController/someAction?device={selected} will be repesented in here -->
</div>
Community
  • 1
  • 1
V H
  • 8,382
  • 2
  • 28
  • 48
  • There is no dependency related selection needed in my application. All dropdowns are independent – Nisha Jul 02 '14 at 16:15
  • There is no dependency related selection needed in my application. All dropdowns are independent. Also, we have huge datasets, hence filtering on these datasets inside the browser is not a good idea. Hence, I somehow want to do the filtering of data (on the dimesions selected in GSP) inside the controller and then send it to browser so that the load to the browser can be reduced. Also,being new to Grails, i don't even know whether this is actually feasible or not.In case you have any suggestions, do let me know.It will be of great help – Nisha Jul 02 '14 at 16:36
  • Oh wait..I have one domain class with many fields(or whatever it is called). These dropdowns that I have mentioned about are few of the various fields inside my domain class.My apologies , if I am being very stupid but , is this what you call a dependent selects?? – Nisha Jul 02 '14 at 17:01
  • And also, why I mentioned that my selects are not inter dependent because, no matter what is selected in the first select, the other selects need to have all the value every time. Hence, I called out them being not dependent. – Nisha Jul 02 '14 at 17:06
  • I am still confused, can you post a sample domainClass example, if you have lets say primary domainClass that has MULTIPLE hasMany relationships so a Country hasMany Cities and Citizens. Are you saying you want the country selected to then show the relevant cities and citizens all together ? if so this is supported in ajaxdependancyselection you just declare domain2 domain3 domain4 etc check the examples further down for multi domain selection.. Or do you wish to create select fields for different fields in one domainClass - set by optionKey optionValue each time... you just declare field nam – V H Jul 02 '14 at 22:33
  • Please have a look at this http://stackoverflow.com/questions/24572811/remotefunction-not-working – Nisha Jul 04 '14 at 11:00