How to create new Object or Cloning of ListGrid in Smart Client

332 views Asked by At

I want to create an object of ListGrid component in Smart Client.

isc.ListGrid.create({
  ID: "countryList",
   width:500, height:224, top:50, alternateRecordStyles:true,
   fields:[
     {name:"countryCode", title:"Flag", width:50, type:"image", imageURLPrefix:"flags/16/", imageURLSuffix:".png"},  
     {name:"countryName", title:"Country"},  
     {name:"capital", title:"Capital"},  
     {name:"continent", title:"Continent"}  
]}) ; 

Now countryList is the ID for the ListGrid component .

Let us suppose that this Grid has possess some values and i want to put some other values like values from database and there is a condition that we don't have to override or change previous values.So we need to create a new object of countryList .

How can we achieve this?

1

There are 1 answers

2
claudiobosticco On BEST ANSWER

I don't understand if you need another instance of the same ListGrid, or if you need to display different data in the same ListGrid.

If you need another instance, you could define a class:

isc.defineClass("MyGrid", "ListGrid");
isc.MyGrid.addProperties({
  width:500, height:224, top:50, alternateRecordStyles:true,
  fields:[
    {name:"countryCode", title:"Flag", width:50, type:"image", imageURLPrefix:"flags/16/", imageURLSuffix:".png"},  
    {name:"countryName", title:"Country"},  
    {name:"capital", title:"Capital"},  
    {name:"continent", title:"Continent"}  
  ]
});
isc.MyGrid.create({ID: "countryList"});
isc.MyGrid.create({ID: "countryList2"});

Otherwise, if you need to show different data in the same ListGrid instance, you could do:

  • countryList.setData(newData); // or:
  • dataSource.fetchData(criteria, "countryList.setData(data)"); // or:
  • countryList.fetchData(newCriteria); // if countryList has a dataSource attribute