logo
down
shadow

Grails dynamic rendering of map-injected g:select


Grails dynamic rendering of map-injected g:select

By : Miro Hassan
Date : November 15 2020, 06:54 AM
help you fix your problem Based on what you have mentioned, you have a couple of different options.
code :
class WidgetController {
    def index() {
        def widgetKeys = getSomehow()
        render (
            view: "widgets",
            model: [ widgets: widgetKeys ]
        )
    }

    def widgetList (String key) {
        def widgetList = getSomehow(key)
        render (
            template: "widgetTemplate",
            model: [ widgetList: widgetList ]
        )
    }
}
<ul>
    <g:each in="${widgetList}">
    <li>${it}</li>
    </g:each>
</ul>
$(function () {
    $('#selectId').on('change', function(){
        var select = this;
        $.ajax({
            url: 'widgetList', //might have to play with this so it is not hardcoded
            data: { 'key': select.value },
            success: function (list) {
                $('#widgetMapping').html(list);
            } 
        });
    })
});


Share : facebook icon twitter icon
Service is not getting injected into Grails domain class , Grails 2.0.0 and 2.0.3

Service is not getting injected into Grails domain class , Grails 2.0.0 and 2.0.3


By : Danielle
Date : March 29 2020, 07:55 AM
may help you . I've tried multiple app restarts, and upgrading from 2.0.0 to 2.0.3, no help. I always get this message: , Just a guess here - the following reads like a getter method:
code :
    def getCustomerName()
    import org.codehaus.groovy.grails.commons.ApplicationHolder as AH
    def customerService = AH.application.mainContext.customerService
grails null value in dynamic select list

grails null value in dynamic select list


By : Moutou
Date : March 29 2020, 07:55 AM
I wish this help you Right before the // Rebuild the select add in a blank option. For example:
code :
var opt = document.createElement('option');
opt.text = ""
opt.value = ""
try {
  rselect.add(opt, null) // standards compliant; doesn't work in IE
} catch(ex) {
  rselect.add(opt) // IE only
}
// Rebuild the select
Grails - Select menu not rendering

Grails - Select menu not rendering


By : dancingllamas
Date : March 29 2020, 07:55 AM
I hope this helps . So I am creating 2 drop down menus, the 2nd of which dynamically changes based off the first. However, the 2nd menu does not render the change, but is providing the correct options when viewing the Post with Firebug. , Try a few modifications - see if makes any difference:
code :
<g:select name="tag.id" from="${Tag.list()}" optionKey="id" optionValue="tagName"
        noSelection="['':'Choose Tag']"
onchange="${remoteFunction (
        controller: 'tag',
        action: 'findSubtagsForTags',
        params: "'tag.id=' + this.value",
        update: 'subtagSelection'
    )}"
 />

<td id="subtagSelection11" valign="top">
<div id="subtagSelection">
<g:select name="subtags.id" id="subtags.id" from="[]"
optionKey="id" noSelection="['': 'Choose Tag']" />
</div>
</td>
grails dynamic select in gsp

grails dynamic select in gsp


By : Ilya
Date : March 29 2020, 07:55 AM
wish of those help Because you're editing the scaffolding view you end up with 2 elements named choosedCert, ideally you'd need to create your own edit.gsp and render only the elements required but as an example I did the following.
Added an Author in BootStrap like so:
code :
def init = { servletContext ->
    new Author( name: 'Dave', email: 'myemail', price1: new BigDecimal(1), price2: new BigDecimal(2), choosedCert: 'FSC' ).save( failOnError: true )
}
...
author.choosedCert = params.availableCert
author.save flush:true
...
...
</fieldset>
    <g:select name="availableCert" from="${author.availableCert}" value="${author.choosedCert}" />
<fieldset class="buttons">
...
Grails rendering a partial template on changes in select

Grails rendering a partial template on changes in select


By : kyle415
Date : March 29 2020, 07:55 AM
Does that help What version of Grails are you using?
remoteFunction was deprecated in 2.4.x
code :
<head>
    <script type="text/javascript">
        function availableProducts(){
            $.ajax({
                url:'${g.createLink( controller:'product', action:'availableProducts' )}',
                data: [sawMill],
                type: 'get'
        }).success( function ( data ) { $( '#divToUpdate' ).html( data ); });
}
    </script>
<body>
    <g:select name="sawMill" from="${millList}" value="" onchange="availableProducts()"/>

    <div id="divToUpdate"></div>
</body>
shadow
Privacy Policy - Terms - Contact Us © ourworld-yourmove.org