Ok Guys, I have fixed it

OverrideDataTableModel:


/**
         * methdo returning the desired data
         */
        public JSONObject getResponse(GridDataSource source){
                
                response.put("sEcho", 
request.getParameter(DataTableConstants.ECHO));
                
                int records = source.getAvailableRows();
            
                response.put("iTotalDisplayRecords", records);  
            
                response.put("iTotalRecords", records);
            
            String displayStart =
request.getParameter(DataTableConstants.DISPLAY_START);
             int startIndex=Integer.parseInt(displayStart);
             
             String displayLength =
request.getParameter(DataTableConstants.DISPLAY_LENGTH);
             
             int rowsPerPage=Integer.parseInt(displayLength);
             
             int endIndex= startIndex + rowsPerPage -1;
             if(endIndex>records-1) endIndex= records-1;
             source.prepare(startIndex,endIndex,sortModel.getSortConstraints() 
);
             
             
             JSONArray rows = new JSONArray();
             
             for(int index=startIndex;index<=endIndex;index++)
             {   
                 JSONObject cell = new JSONObject();
                 
                 Celebrity obj = (Celebrity) source.getRowValue(index);
                 
                 List<String> names = model.getPropertyNames();
                 
                 for (String name: names)
                 {
                         Object val;

                         if(name.equals("view")){
                                 //We add the content of the extra column
                                 
                                 //We use the ComponentResources service, for 
creating an EventLink
                                 //We will add the id of the current element as 
a context of the
event link
                                 val = String.format(" Update <%s> 
",linkSource.createPageRenderLinkWithContext(DataTableAjaxWithNewColumn.class,obj.getId()).toURI());
                                                 
                         }
                         else {
                                 PropertyConduit conduit = 
model.get(name).getConduit();
                                 String cellValue;
                                 Class type = conduit.getPropertyType();
                                 
                                 val = conduit.get(obj) != null ? 
conduit.get(obj) : "";
                                         
                                        if 
(!String.class.equals(model.get(name).getClass())
                                    &&
!Number.class.isAssignableFrom(model.get(name).getClass()))
                                {
                                    Translator translator =
translatorSource.findByType(model.get(name).getPropertyType());
                                    if (translator != null)
                                    {
                                        val = translator.toClient(val);
                                    }
                                    else
                                    {
                                        val = val != null ? val.toString() : "";
                                    }
                                }
                                 }
                     cell.append(name, val);
                 }       
                                 
                 rows.put(cell);
             }
            
                response.put("aaData", rows);
                
                return response;
        }



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/datatable-ajax-with-new-column-tp5719395p5719409.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to