GeeCON Prague 2014*
The moose likes Groovy and the fly likes how to get ColNames and colModel from the controller in grails jqgrid ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Languages » Groovy
Bookmark "how to get ColNames and colModel from the controller in grails jqgrid ?" Watch "how to get ColNames and colModel from the controller in grails jqgrid ?" New topic
Author

how to get ColNames and colModel from the controller in grails jqgrid ?

Nazeer Ahammad
Ranch Hand

Joined: Feb 26, 2012
Posts: 43
Hi All,

I'm using JQgrid plugin(version 1.3.8) in grails (vesrion 2.2.4) .I want get colNames and ColModel from controller. How we can get this one ?

Example:-

__________
Controller
__________

MyController{

def columndetails={
def columnname="id,name"
render columnname as json
}

def colmodeldetails={
def details="{name:'companyname', editable: true},{name:'id',hidden:true}"
render details as json
}
}

_______
GSP
________
$(document).ready(function() {

// $.ajax({url: 'http://localhost:8080${createLink(action: 'colnames')}', success: function(data) { alert('hai'); } });
//alert("'${createLink(action: 'colnames')}'");
<jqgrid:grid
id="contact"
url="'${createLink(action: 'listJSON')}'"
editurl="'${createLink(action: 'editJSON')}'"
colNames= //Here what i have to written to call columndetails to get column names from Mycontrollee
colModel= //Here what i have to written to call colmodeldetails to get column details from Mycontrollee
sortname="'companyname'"
caption="'Company List'"
height="300"
autowidth="true"
scrollOffset="0"
viewrecords="true"
showPager="true"
datatype="'json'"
beforeSelectRow= "function (id) {
if (id !== lastsel2) {
jQuery(this).restoreRow(id,true);
lastsel2 = id;
}
return true;
}"

ondblClickRow="function(id)
{
var rowData = jQuery(this).editRow(id,true);
lastsel2=id;
}"



>

<jqgrid:filterToolbar id="contact" searchOnEnter="false" />
<jqgrid:navigation id="contact" add="true" edit="true"
del="true" search="true" refresh="true"
/>


<jqgrid:resize id="contact" resizeOffset="-2" />
</jqgrid:grid>







});


Regards,
Nazeer.....
Nazeer Ahammad
Ranch Hand

Joined: Feb 26, 2012
Posts: 43
Hi got the answer ..............................


If i use below code in gsp it is working

<g:set var="colnames" value="${new MyController().colnames()}" />
<script>
$(document).ready(function() {
...................

colNames="${colnames}"

....................

</script>

And i altered the controller like below
------------------------------------------
Class MyController
{
def colnames()
{
return "id,name".toString()
}
}


Same for coldetails also


Regards,
Nazeer
 
GeeCON Prague 2014
 
subject: how to get ColNames and colModel from the controller in grails jqgrid ?