Display list of records

lamson_
Giga Contributor

Hello ladies and gentlemen,

I would like to know how to show the list of record from the same table in a widget.

I have a balise <div></div> and i would like to have each line a record from the table ( if possible display only specifics fields and have the record filtered)

Best regards,

Maxime Nguyen.

1 ACCEPTED SOLUTION

Hi Rushit,



Thanks for your answer, while it is true that it display records from table i wanted to do code it, I found a way to display the list without calling an widget, here is an example:



HTML Template


  <p ng-model="typevm"     ng-change="c.Calcul_Price()">


        <a


                    ng-repeat="item in data.type_vm"


                    value="{{item.value}}">


                    {{item.label}} <br/>


            </a>


  </p>



Server Script



var grTypeVM = new GlideRecord('sys_choice');


grTypeVM.addEncodedQuery( ' ..... ' );


grTypeVM.query();


data.type_vm = [];



while (grTypeVM.next())


{


var record ={};


var fields = grTypeVM.getFields();


for (var i = 0; i < fields.size(); i++) {


var glideElement = fields.get(i);


var name = glideElement.getName();


if (name.indexOf("sys_") == -1)


record[name] = grTypeVM.getValue(name);


}


data.type_vm.push(record);


}


View solution in original post

3 REPLIES 3

Rushit Patel2
Tera Guru

Hi,



there is Data Table(widget-data-table) widget out of box which you can add to any page you want...then you can configure instance options where you can specify table name , fields and filter.



find_real_file.png



then


find_real_file.png



and you have to mention which view to show like below...then create/update list view with whatever fields you want to show



find_real_file.png




(please mark helpful/like/correct if it helps)


Hi Rushit,



Thanks for your answer, while it is true that it display records from table i wanted to do code it, I found a way to display the list without calling an widget, here is an example:



HTML Template


  <p ng-model="typevm"     ng-change="c.Calcul_Price()">


        <a


                    ng-repeat="item in data.type_vm"


                    value="{{item.value}}">


                    {{item.label}} <br/>


            </a>


  </p>



Server Script



var grTypeVM = new GlideRecord('sys_choice');


grTypeVM.addEncodedQuery( ' ..... ' );


grTypeVM.query();


data.type_vm = [];



while (grTypeVM.next())


{


var record ={};


var fields = grTypeVM.getFields();


for (var i = 0; i < fields.size(); i++) {


var glideElement = fields.get(i);


var name = glideElement.getName();


if (name.indexOf("sys_") == -1)


record[name] = grTypeVM.getValue(name);


}


data.type_vm.push(record);


}


yes..you can always code stuff...fetch any data from server and display using HTML.



my answer was more related to Out of box functionality and for someone who is not pro at coding