Frage

I am working on spring and hibernate i am using Flexigrid ( http://flexigrid.info/ ) to display data entered by user in a registration form. registration form have a dynamic drop down box (i.e combobox it fetch data from another table) after submitting registration form data will save in database and drop down data also save in database as it's ID (because registration form have ' many to one ' relationship for drop down box) but my problem is it show [object object] while displaying

This is my .js file

$(document).ready(function() {
    $("#stockEntryGrid").flexigrid({
        url: '../stockEntry/list.action',
        dataType: 'json',
        colModel : [
            {display: 'ID', name : 'id', width : 100,sortable : true, align: 'left'},
            {display: 'Accession Number', name : 'accnNumber', width : 100,sortable : true, align: 'left'},
            {display: 'Stock User Number ', name : 'stockverificationnumbermaintainance.id', width : 100,sortable : true, align: 'left'},
            {display: 'Catalogue Num', name : 'catalogueCopyDetails.accnNo', width : 100,sortable : true, align: 'left'}
            ],
            buttons : [{id : 'addSub', name: 'Add', bclass: 'add', onpress : newStockEntry},
                       {name: 'Delete', bclass: 'delete', onpress : deleteStockEntry},
            {separator: true}
            ],
        searchitems : [
            {display: 'Subject Name', name : 'code'}
            ],
        sortname: "id",
        sortorder: "asc",
        usepager: true,
        title: 'Stock Entry',
        useRp: true,
        rp: 10,
        showTableToggleBtn: true,
        width: 950,
        height: 200
    });   
});

what i want is, this is the line which show drop down data

{display: 'Stock User Number ', name : 'stockverificationnumbermaintainance.id', width : 100,sortable : true, align: 'left'}

i able to get data from json but while displaying it show [object object] i think i am not following proper syntax for displaying you can see below attached image.

image

War es hilfreich?

Lösung

In Hibernate Pojo class you have to get the object of another class and set that value to one transient variable then use that transient variable for displaying.Like following manner..

private StockNumberMainteinance stockverificationnumbermaintainance;

@Transient
public String getId() {
    if(stockverificationnumbermaintainance != null)
    {
        id=stockverificationnumbermaintainance.getId();

    }

    return id;
}

public void setId(String id) {
    this.id = id;
} 

If you want any other values in place of id then replace with the hibernate pojo class variable name..

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top