Update grid data on click event

I have this code. Here I am returning a new set of values ​​via the URL via Jquery Ajax ($. Get ()) when the gotoa () function is called for some click event. I get the set of values ​​correctly, as I get the correct result when notified. But at this moment the grid is not updated. When I refresh the whole page, the grid updates. How to update the grid when calling gotoa ().?

The code::

<script type="text/javascript">
function gotoa(){
    $.get("http://localhost:8080/2_8_2012/jsp/GetJson.jsp?random=" + new Date().getTime(), function(result){

            alert(result);
            var storedata={
                identifier:"ID",
                label:"name",
                items:result
        };


    var store = new dojo.data.ItemFileWriteStore({data: storedata});
    alert(store);
    //var gridh = dijit.byId("gridDiv");
    //gridh.setStore(store);


        var gridStructure =[[

                          { field: "ID",
                                name: "ID_Emp",
                                width: "20%",
                                classes:"firstname"
                          },
                          {
                              field: "Names",
                              name: "Name",
                              width: "20%",
                              classes: "firstname"
                          },
                          { field: "Email",
                                name: "Mail",
                                width: "20%",
                                classes:"firstname"
                          }

                    ]
              ];


         var grid1 = new dojox.grid.DataGrid({
                id: 'grid2',
                store: store,
                structure: gridStructure,
                rowSelector: '30px',
                selectionMode: "single",
                autoHeight:true,
                columnReordering:true},
              document.createElement('div'));

            /*append the new grid to the div*/
            dojo.byId("gridDiv").appendChild(grid1.domNode);

            /*Call startup() to render the grid*/
            grid1.startup();

         // assuming our grid is stored in a variable called "myGrid":
            dojo.connect(grid1, "onSelectionChanged", grid1, function(){
                var items = grid1.selection.getSelected();



            //  do something with the selected items
                dojo.forEach(items, function(item){
                    var v = grid1.store.getValue(item, "Names");

                    function showDialog() {
                        dojo.require('dijit.Tooltip');
                        dijit.byId("terms").show();
                    }
                    //if(name!="Mail")
                    showDialog();
                    }, grid1);

            });


            dojo.connect(grid1, "onCellClick", grid1, function sendmail(){
                var items = grid1.selection.getSelected();

                dojo.forEach(items, function(item){
                    var v1 = grid1.store.getValue(item, "Email");      
                    alert(v1);
                    request.setAttribute("variablemail", v1);
            });

        });


    },"text");

    }

</script>

The output of the warning (result) at a certain point in time is as follows:

[{"ID":1,"Names":"Shantanu","Email":"shantanu.tomar@gmail.com"},{"ID":2,"Names":"Mayur","Email":"mayur.sharma@gmail.com"},{"ID":3,"Names":"Rohit"},{"ID":4,"Names":"Jasdeep"},{"ID":5,"Names":"Rakesh","Email":"rakesh.shukla@gmail.com"},{"ID":6,"Names":"Divyanshu"},{"ID":8,"Names":"hello"},{"ID":9,"Names":"fine"},{"ID":10,"Names":"shivani"}]

And the warning output (store) is similar to ::

[object Object]

And I call gotoa () when clicked anywhere inside the content area (for now, a button or something else will be placed later), like this:

<div dojoType="dijit.layout.ContentPane" title="Pending Activities" style="background-image: url('http://localhost:8080/2_8_2012/images/17.png');" onClick="gotoa();">

How to update grid data? Thank you

0
1

dojo, , :

<script type="text/javascript">
function gotoa(isUpdate){
    $.get("http://localhost:8080/2_8_2012/jsp/GetJson.jsp?random=" + new Date().getTime(), function(result){

            alert(result);
            var storedata={
                identifier:"ID",
                label:"name",
                items:result
        };


    var store = new dojo.data.ItemFileWriteStore({data: storedata});
    alert(store);
    if (isUpdate) {
       var grid = dojo.byId('grid2');
       grid.setStore(store);
    } else {


        var gridStructure =[[

                          { field: "ID",
                                name: "ID_Emp",
                                width: "20%",
                                classes:"firstname"
                          },
                          {
                              field: "Names",
                              name: "Name",
                              width: "20%",
                              classes: "firstname"
                          },
                          { field: "Email",
                                name: "Mail",
                                width: "20%",
                                classes:"firstname"
                          }

                    ]
              ];


         var grid1 = new dojox.grid.DataGrid({
                id: 'grid2',
                store: store,
                structure: gridStructure,
                rowSelector: '30px',
                selectionMode: "single",
                autoHeight:true,
                columnReordering:true},
              document.createElement('div'));

            /*append the new grid to the div*/
            dojo.byId("gridDiv").appendChild(grid1.domNode);

            /*Call startup() to render the grid*/
            grid1.startup();

         // assuming our grid is stored in a variable called "myGrid":
            dojo.connect(grid1, "onSelectionChanged", grid1, function(){
                var items = grid1.selection.getSelected();



            //  do something with the selected items
                dojo.forEach(items, function(item){
                    var v = grid1.store.getValue(item, "Names");

                    function showDialog() {
                        dojo.require('dijit.Tooltip');
                        dijit.byId("terms").show();
                    }
                    //if(name!="Mail")
                    showDialog();
                    }, grid1);

            });


            dojo.connect(grid1, "onCellClick", grid1, function sendmail(){
                var items = grid1.selection.getSelected();

                dojo.forEach(items, function(item){
                    var v1 = grid1.store.getValue(item, "Email");      
                    alert(v1);
                    request.setAttribute("variablemail", v1);
            });

        });
        }

    });

    }

</script>

gotoa() gotoa(true) .

0

All Articles