EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: pams on September 01, 2019, 07:15:21 PM



Title: Combogrid consume API
Post by: pams on September 01, 2019, 07:15:21 PM
Hi...

I have json data from other developer like this:
{
    "status": {
        "error": false,
        "message": "",
        "code": 200
    },
    "data": [
        {
            "RowNumber": "1",
            "id": "01",
            "kode": "101",
            "nama": "HEAD OFFICE",
            "idregion": {
                "RowNumber": "1",
                "id": "11111",
                "kode": "1",
                "nama": "SOME CITY"
            },
            "kodeRegion": "1",
            "namaRegion": "SOME CITY"
        },{
            "RowNumber": "22",
            "id": "22",
            "kode": "322",
            "nama": "SAMPLE BRANCH",
            "idregion": {
                "RowNumber": "1",
                "id": "11113",
                "kode": "3",
                "nama": "SAMPLE REGION"
            },
            "kodeRegion": "3",
            "namaRegion": "SAMPLE REGION"
        }
    ],
    "meta": {
        "more": false,
        "cursor": {
            "count_rec": 22,
            "count_data": 22,
            "count_page": 1,
            "curr_page": 1,
            "next_page": 0
        }
    }
}

as you can see, there's no "rows" element in the json data.

how can i populate that json to combogrid..?

thanks a lot...


Title: Re: Combogrid consume API
Post by: jarry on September 03, 2019, 02:23:24 AM
Define the 'loadFilter' function to convert the original data to the desired data format.
Code:
$('#cg').combogrid({
data: data,
loadFilter: function(data){
return data.data;
}
})