Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Nazeer Ahammad
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic