Question

i have a jsp page where i am displaying my books detail in Struts2 jquery grid. Now i want to call an action and pass rowid as a parameter to the the action class on the click of a row from my Jquery grid. And i also i want to specify the target of my div to refresh after calling my action.

These stuffs i know nicely through <sj:submit target="targetDivToRefresh" formId="form2" button="true"/> but i don't know how to do these task "when users click a row from my struts2 jquery grid".

Please help me to solve this issue.

my jsp page

    <sjg:grid
        id="bookgrid" 
        editurl="%{bookediturl}"
        navigator="true" 
        editinline="true" 
        navigatorSearch="false"
        autowidth="false"   
        width= "1550" 
        viewrecords="true"  
        navigatorRefresh="true"
        navigatorDelete="true">
    <sjg:gridColumn name="id" index="locationId" title="ID" formatter="integer" sortable="false" key="true" 
                       search="false"  editable="true"  hidden="true"   /> 
     <sjg:gridColumn name="authLastname" index="authLastname" title="AuthorLastname" sortable="true" search="true" editrules="{required: true}"
                        editable="true" edittype="text" />  
 </sjg:grid> 
Was it helpful?

Solution

try this:

$(function(){
    $.subscribe('rowselect', function(event,data) {
        alert(event.originalEvent.authLastname);
        $("#targetDivToRefresh").load('your-struts2-action');
    });
});

UPDATE

$("#targetDivToRefresh").load('your-struts2-action');

Reference Link: Struts2 jquery plugin showcase

Please make sure this event will be triggered, if you click on a row, i added test code alert() to make sure, it has been called during the event. there is still a thing, that i have to tell, you have to register your selectrow event in your <sj:grid> tag using onSelectRowTopics="rowselect"

UPDATE

$("#targetDivToRefresh").load("<s:url value="your-struts2-action"/>"+"?id="+event.originalEvent.id);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top