Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by shweta on Nov 26, 2008 20:12
open dhtmlx forum
sub_row in dhtmlxgrid

i'm using sub row in dhtmlx grid.Now i want to call server side method on exapansion of row.and the data from serverside method is to be shown in subrow of that row.Is it possible to do it in dhtmlxgrid?

Please provide me proper solution for it.
Here i'm attaching jsp in which i'm creating that grid.



tab_maintain.jsp




<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*,java.util.*,com.motorola.mwb2.vo.*,com.motorola.mwb2.frontend.actionform.SortSearchForm" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<div style="width:99%; float:left; ">
                <div id="maintainPagingArea"><div id="maintainPager"> </div></div>
                <div style="float:right ">
                    <select id="filterColumnMaintain">
                         <option value='4'>PO Number</option>
                         <option value='5'>Source</option>
                         <option value='6'>Part Number</option>
                         <option value='7'>Line Amount</option>
                         <option value='8'>Supplier Name</option>
                         <option value='9'>IN</option>
                         <option value='10'>OUT</option>
                         <option value='11'>Cancel</option>
                         <option value='12'>Facility</option>
                         <option value='13'>Buyer Name</option>
                         <option value='14'>First Delievry</option>
                         <option value='15'>Value To Cancel</option>
                     </select>
                    <input name="textfield" type="text" size="20" id="filterValueMainatin"/>
                    <input type="button" value="Find" onclick="filterData();"/>
                </div>
</div>
<div id="maintainPane" style="height:320px;padding:0; width:966px;"> </div>

<script language="javascript">
var maintainGrid = null;



doInitGridForMaintain();
//Loading Grid for Maintain Tasks
function doInitGridForMaintain(){
    if( maintainGrid==null){
            maintainGrid = new dhtmlXGridObject('maintainPane');
            window.maintainGrid = maintainGrid;
    }
    maintainGrid.enablePaging(true,50,2,"maintainPagingArea",true,"maintainPager");
    maintainGrid.setImagePath("<%=request.getContextPath()%>/js/codebase/imgs/");

    maintainGrid.setHeader(" , ,img:[images/r_flag.gif],<a href='#'><font color='#000000'>Sr.#</font></a>,<a href='#'><font color='#000000'>PO #</font></a>,<a href='#'><font color='#000000'>Source</font></a>,<a href='#'><font color='#000000'>Part #</font></a>,<a href='#'><font color='#000000'>Line<br>Amount</font></a>,<a href='#'><font color='#000000'>Supplier Name</font></a>,<a href='#'><font color='#000000'>IN</font></a>,<a href='#'><font color='#000000'>OUT</font></a>,<a href='#'><font color='#000000'>CANCEL</font></a>,<a href='#'><font color='#000000'>Facility</font></a>,<a href='#'><font color='#000000'>Buyer<br>Name</font></a>,First<br>Delivery, <a href='#'><font color='#000000'>$value to<br>Cancel</font></a>,pid,itemcount");

    maintainGrid.enableAutoHeight(false);
    maintainGrid.enableAutoWidth(false);

    maintainGrid.setInitWidths("20,23,25,30,120,70,70,65,90,40,40,60,75,70,80,70,10,10");
    maintainGrid.setColTypes("ch,sub_row,ro,ro,ro,ro,ro,price,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro");
    maintainGrid.setColAlign("left,left,left,left");
    maintainGrid.setColSorting(",,str,int,str,str,str,str,str,str,str,str,str,str,str,int,int,int");
    maintainGrid.enableTooltips("true,true,false,true,true,true,true,true,true,true,true,true,true,true,true,true,true");
    maintainGrid.setSkin("MWB2");
    maintainGrid.entBox.onselectstart = function(){ return true; };
    maintainGrid.setColumnHidden(16,"true");
    maintainGrid.setColumnHidden(17,"true");
    maintainGrid.init();


<%
                List voList=(ArrayList)request.getSession().getAttribute("SortSearchResults");
                request.getSession().removeAttribute("SortSearchResults");
                java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("dd-MMM-yyyy");
                
                 for(int i = 0 ; i < voList.size() ; i++){
                SortSearchVO ssVO = (SortSearchVO)(voList.get(i));
                int savvionId=ssVO.getSavvionId();
                
                String url=" ";
                    if(ssVO.getIsAssignedTask()==1){
                        url = "<img src='images/r_flag.gif'>";
                    }else if(ssVO.getIsSavedTask()==1){
                        url = "<img src='images/blueflag.gif'>";                        
                    }
                    String partDesc = ssVO.getPartDesc();
                    if(partDesc!=null){
                    partDesc = partDesc.replaceAll(","," ");
                    }else{
                    partDesc = "";
                    }
                    String headerNote = ssVO.getHeaderNote();
                    if(headerNote!=null){
                    headerNote = headerNote.replaceAll(","," ");
                    }else{
                    headerNote = "";
                    }
                    String buyerName = ssVO.getBuyerName();
                    if(buyerName!=null){
                    buyerName = buyerName.replaceAll(","," ");
                    }else{
                    buyerName = "";
                    }
                    String supplierName = ssVO.getSupplierName();
                    if(supplierName!=null){
                    supplierName = supplierName.replaceAll(","," ");
                    }else{
                    supplierName = "";
                    }
                String firstDeliveryDate = null;
                String quotaionstart=null;
                String quotationend=null;
                if(ssVO.getFirstDeliveryDate() != null )
                    firstDeliveryDate = sdf.format(ssVO.getFirstDeliveryDate());
                 if(ssVO.getQuotationStartDate() != null )
                    quotaionstart = sdf.format(ssVO.getQuotationStartDate());
                 if(ssVO.getQuotationEndDate() != null )
                    quotationend = sdf.format(ssVO.getQuotationEndDate());
                
%>


    maintainGrid.addRow(<%=i+1%>,"0,"+
                "<table align='left'><tr>"+
" <td> </td>"+
" <td> </td>"+
"<td> </td>"+
"<td></td>"+
" <td colspan='4' class='normal_small_black_font'>Supplier Code: "+
                    "<span style='color:#000000'><strong><%=ssVO.getSupplierCode()%></strong></span></td>"+
                 "<td> </td>"+
                 " <td> </td>"+
" <td> </td>"+
"<td> </td>"+

" <td colspan='4'><span class='normal_small_black_font'>Buyer: </span>"+
                    "<span style='color:#000000'><strong> <%=buyerName%></strong> </span></td>"+
"<td> </td>"+
                     
                    " <td colspan='2'><span class='normal_small_black_font'>Qty: </span>"+
                    "<span style='color:#000000'><strong> <%=ssVO.getItemQty()%></strong> </span></td>"+
"<td> </td>"+

                    " <td colspan='2'><span class='normal_small_black_font'>Unit Cost </span>"+
                    "<span style='color:#000000'><strong> <%=ssVO.getUnitPrice()%></strong> </span></td>"+
"<td colspan='2' class='normal_small_black_font'> </td>"+
"<td colspan='2' class='bold_small_black_font'> </td>"+
                     "<td> </td>"+
                     "<td colspan='2' class='normal_small_black_font'>Part Decription: </td>"+
"<td style='color:#000000'><strong><%=partDesc%></strong></td>"+
"<td> </td>"+
" </tr><tr> </tr>"+
                         "<tr>"+
" <td> </td>"+
" <td> </td>"+
"<td> </td>"+
"<td><div align='left'></div></td>"+
" <td colspan='4' class='normal_small_black_font'>Line Type: "+
                    "<span style='color:#000000'><strong><%=ssVO.getLineType()%></strong></span></td>"+
                 "<td> </td>"+
                 " <td> </td>"+
" <td> </td>"+
                     "<td> </td>"+
"<td colspan='2' class='normal_small_black_font'># of Items: </td>"+
"<td style='color:#000000'><strong><%=ssVO.getNoOfItems()%></strong></td>"+
"<td> </td>"+

" <td colspan='5'><span class='normal_small_black_font'>Header Note: </span>"+
                    "<input type='textarea' value='<%=headerNote%>' readonly/></td>"+
"<td colspan='2' class='normal_small_black_font'> </td>"+
"<td colspan='2' class='bold_small_black_font'> </td>"+
"<td> </td>"+
                
"<td> </td>"+
" </tr>"+
                         "<tr>"+
" <td> </td>"+
" <td> </td>"+
"<td> </td>"+
"<td></td>"+
" <td colspan='4' class='normal_small_black_font'>Quote Start Date: "+
                    "<span style='color:#000000'><strong><%=quotaionstart%></strong></span></td>"+
                 "<td> </td>"+
                 " <td> </td>"+
" <td> </td>"+
"<td> </td>"+
"<td colspan='2' class='normal_small_black_font'>Quote End Date: </td>"+
"<td style='color:#000000'><strong><%=quotationend%></strong></td>"+
"<td> </td>"+
" <td colspan='5'><span class='normal_small_black_font'>PO Value: </span>"+
                    "<span style='color:#000000'><strong> <%=ssVO.getPoValue()%></strong> </span></td>"+
"<td colspan='2' class='normal_small_black_font'> </td>"+
"<td colspan='2' class='bold_small_black_font'> </td>"+
"<td> </td>"+
"<td> </td>"+
                     " <td colspan='5'><span class='normal_small_black_font'>PO Status: </span>"+
                    "<span style='color:#000000'><strong> <%=ssVO.getPoStatus()%></strong> </span></td>"+
"<td colspan='2' class='normal_small_black_font'> </td>"+
"<td colspan='2' class='bold_small_black_font'> </td>"+
"<td> </td>"+
"<td> </td>"+
" </tr></table>"+
",<%=url%>,<%=i+1%>,<a href='#' onclick='gridValueLink(<%=i+1%>)' ><%=ssVO.getPoNumber()%></a>,<%=ssVO.getDemandSource()%>,<%=ssVO.getPartNo()%>,<%=ssVO.getAmount()+""%>,<%=supplierName%>,<%=ssVO.getMaxActionDaysIn()%>,<%=ssVO.getMaxActionDaysOut()%>,<%=ssVO.getCancelFlag()%>,<%=ssVO.getMotorolaFacility()%>,<%=buyerName%>,<%=firstDeliveryDate%>,<%=ssVO.getCancelCost()%>,<%=savvionId%>,<%=ssVO.getNoOfItems()%>");
        
    <%}%>
    
        
}

</script>

Answer posted by Support on Nov 27, 2008 01:49
You can use sub_row_ajax column type, which work in necessary way ( it call a server side method on opening and show response inside panel. 

>> maintainGrid.setColTypes("ch,sub_row,
 maintainGrid.setColTypes("ch,sub_row_ajax,
...
 maintainGrid.addRow(<%=i+1%>,"0,"some.jsp?content=for"); 

On item opening , the related uri - "some.jsp?content=for" - will be called.