narentera / flexigrid

Automatically exported from code.google.com/p/flexigrid
0 stars 0 forks source link

Populate Flexigrid via Servlet #68

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I'm trying to use a Java Servlet to populate my flexigrid but I have been 
unsuccessful.  Below, I successfully connect to the "doGet" method in my 
UserSearch servlet.  How does the servlet get the json response back to the 
flexigrid?  

My return object looks like this:

{"count":1, "page":1, "rows":["test@test.com"]}

<script language=JavaScript>
            function callback(data, status) {
                alert("Test 1");
            }

            $("#userGrid").flexigrid({
                url: 'TestProject/UserSearch',
                method: 'GET',
                dataType: 'json',
                colModel : [
                    {display: 'Email', name : 'email', width : 40, sortable : true, align: 'center'},
                    ],
                searchitems : [
                    {display: 'Email', name : 'email', isdefault: true}
                    ],
                sortname: "email",
                sortorder: "asc",
                usepager: true,
                title: 'Users',
                useRp: true,
                rp: 15,
                showTableToggleBtn: true,
                width: 700,
                height: 200
            });
        </script>
<table class="userGrid" style="display:none" ></table>

Original issue reported on code.google.com by derekada...@gmail.com on 22 Aug 2011 at 10:00

GoogleCodeExporter commented 8 years ago
It looks like their is something wrong with the formatting of the json return 
object...?

I found a decent example that looks to have better formatting, but this still 
doesn't work:

{
    "total":4,
    "page":1,
    "rows":[
        {"id":"email","cell":"test@test.com"},
        {"id":"email","cell":"asdf@asdf.com"},
        {"id":"email","cell":"jfjfjfjfjf@jfjfjfj.com"},
        {"id":"email","cell":"blake@blake.me"}
    ]
}

Original comment by derekada...@gmail.com on 24 Aug 2011 at 9:47

GoogleCodeExporter commented 8 years ago
This is a sample of my JSON and works fine.

{
    "page": 1,
    "total": 1,
    "rows": [{"id":"311169","cell": {
                "endereco":"AVENIDA PREFEITO ERASTO GAERTNER","bairro":"BACACHERI","cidade":"CURITIBA","estado":"PARANÁ","uf":"PR","cep":"82510160","paginas":"1","area":"cep","lote":"LOTE_PR","doc":"311169"
            }]
}

Original comment by Vormav...@gmail.com on 27 Aug 2011 at 7:18