1

i have 1 @RemoteAction method which is returning map<String,map<String,String>> and i need to bind this with vf page. and this is the code i did till now :

        <div id="data" class="container-fluid" style="padding-top: 20px;">
            <div style="padding: 10px;">
                <br />
                <h3> 
                    data
                </h3>
                <table id="table" data-group-by="true" data-group-by-field="name"
                    data-search="true" data-show-columns="true" data-pagination="false"
                    data-page-size="10">
                    <thead>
                        <tr>
                            <th data-field="name" data-sortable="true"> Name</th>
                            <th data-field="data" data-sortable="true"> # data </th>
                        </tr>
                    </thead>
                </table>
            </div>
        </div>

   <script type="text/javascript">
        var c = c || {};
        c.loadMapData = function(){
            Visualforce.remoting.Manager.invokeAction(
                '{!$RemoteAction.Controller.getMapData}',
                function(result, event){

                    //if success
                    if (event.status) {

                        c.loadmapDatas(result);


                    } else if (event.type === 'exception') {
                       alert('Error loading Data.');
                    }
                }, 
                {    buffer: false
                    ,escape: true
                }
            );

        };


        c.loadmapDatas = function(datas){


            $('#table').bootstrapTable({
                data : datas,
                groupByField : "",
                groupBy : false,
            });

        };



        $(document).ready(function(event){
            c.loadMapData();

        });

       </script>

any help is appreciated !!!

5
  • What do you mean by bind to vf page? Apex Object is automatically converted into JSON and JavaScript Object when vf page is rendered.
    – Jun Ke
    Commented Apr 25, 2016 at 15:15
  • thanks for reply @JunKe by binding i mean to show that map on vf page by using javascript remoting Commented Apr 25, 2016 at 15:27
  • result in function(result, event) is binding with map<String,map<String,String>>. It's already a javascript object, you can try console.log(result) and see the structure of result using chrome dev console.
    – Jun Ke
    Commented Apr 25, 2016 at 15:37
  • ya i saw that @JunKe but i need to bind that map in bootstrap table ..and i m stuck in that logic for binding to table Commented Apr 25, 2016 at 15:46
  • I think you may see the documentation of bootstrap table, bootstrap-table.wenzhixin.net.cn/documentation/#methods. In the documentation, the data option in bootstrapTable function is of type array, while datas in your code is not an array. I think you should firstly convert the datas into something of array type.
    – Jun Ke
    Commented Apr 25, 2016 at 16:02

0

You must log in to answer this question.

Browse other questions tagged .