|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Grails UI : Adding metafields in the response schemaHow do I handle extra metadata that I want to pass through the JSON response in a gui:dataTable
I am using the gui:datatable and want to add an extra field in the datasource responseSchema. Currently only , the totalRecords gets added by default to the response schema. for e.g. the method called by the datatable which recieves a JSON response is def getDataAsJSON ={ def results = Albums.list() def data = [ results: results, totalRecords: results.totalCount, something: "useful" ] render data as JSON } I want to capture 'something' in my response. Is there a way to do it ? |
|
|
Re: Grails UI : Adding metafields in the response schemaDo you want to add the same data for every call the DataTable makes? That would be easy. Just add a params="${[key:'value']}" into your attributes.
If you want the parameters to be condition depending other data on the page.... that will be harder, and you'll have to get into the JavaScript. Let me know if it is the latter and I'll try to look into it, but it is not a simple thing. --- Matthew Taylor http://dangertree.net On Thu, Nov 5, 2009 at 10:49 PM, Grailzzz <kapilmistry@...> wrote:
|
|
|
Re: Grails UI : Adding metafields in the response schemaMatt ,
I want to pass a different value every time to my datatable through the metadata field. I have tabView , autoComplete and a dataTable on the same page & I wanted the tabLabel to be updated everytime the dataTable was refreshed.The tab Label is sent through the metadata field of the dataTable.(The metadata field is called 'tabLabel'). I dont know if this is the best way to do it but this is how I am doing it: function getMetaData(query){ var myTabs = new YAHOO.widget.TabView('inboxTabView'); var tab0 = myTabs.getTab(0); var myDataTable = GRAILSUI.tableName; myDataTable.getDataSource().responseSchema = { resultsList : 'results', fields : ["id","albumId"], metaFields : { totalRecords: 'totalRecords', tabLabel:'tabLabel' } }; var oCallback = { success : myDataTable.onDataReturnInitializeTable, failure : myDataTable.onDataReturnInitializeTable, scope : myDataTable, argument: myDataTable.getState() }; myDataTable.handleDataReturnPayload = function(oRequest, oResponse, oPayload) { oPayload.totalRecords = oResponse.meta.totalRecords; tab0.set("label", oResponse.meta.tabLabel); return oPayload; }; myDataTable._oDataSource.sendRequest('&query='+ query, oCallback); } Please let me know if there is a better way or if you plan to support extra metadata fields inside the gui:dataTable. Thanks for you time. Kapil
|
|
|
Re: Grails UI : Adding metafields in the response schemaOk, I see what you are trying to do now. I haven't tried this, but you might be able to just code the controller that populates the JSON response and add more key:value pairs adjacent to the totalRecords. I'm not sure if the DataTable will choke on that without making some of the changes you've managed.
Also try to add an event handler for the dataReturnEvent: http://developer.yahoo.com/yui/docs/YAHOO.widget.DataTable.html#event_dataReturnEvent Here you'll get the full response object before the DataTable has a chance to consume it. You might even be able to pull out your extra data here in case the DataTable doesn't like the extra data. Let me know if you try that and how it works. --- Matthew Taylor http://dangertree.net On Fri, Nov 6, 2009 at 6:11 PM, Grailzzz <kapilmistry@...> wrote:
|
| Free embeddable forum powered by Nabble | Forum Help |