0

I am new to Power Builder and I would like to ask how can I represent my objects in a table form. For example, given an ArrayList in java I have implemented the code like this:

    table = new JTable();
    scrollPane.setViewportView(table);


    DefaultTableModel tableModel = 
            new DefaultTableModel(
                        new String[] {
                                "ScheduleNo", 
                                "Start Date", 
                                "End Date", 
                                "No of days", 
                                "Principal Expected", 
                                "Interest Expected", 
                                "EMI amount", 
                                "Factor", 
                                "MeanFactor"}
                        , 0);

    for (Schedule s : pf.getSchedules()){
           Integer schNo  = s.getScheduleNo();
           String startDate = df.format(s.getStartDate());
           String endDate = df.format(s.getEndDate());
           Integer noofdays = s.getNoOfDays();
           String prinExp = String.format("%.2f", s.getPrincipalAmt());
           String intExp = String.format("%.2f", s.getInterestAmt());
           String emi = String.format("%.2f", s.getAmortizedAmount());
           String factor = String.format("%.6f", s.getFactor());
           String mean = String.format("%.6f", s.getProductByFactor());


           Object[]data = {schNo, startDate, endDate, noofdays, prinExp, intExp, 
                   emi, factor, mean};

           tableModel.addRow(data);
        }

    table.setModel(tableModel);

But I cannot find a way to do it in PowerBuilder without having a connection to a database and pick the data from there which is totally not the case.

The data come from an User Object array[] and have exactly the same form like in the Java example above.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

2 Answers2

1

Without really knowing what you are trying to accomplish it appears to me that you could use a 'normal' PowerBuilder datawindow but when you define it you make it's datasource as external. This type of datawindow does not require a connection to a database. You define the 'fields' of the datasource as strings, numeric, etc. when you create it.

In code you can create a datawindow (or datastore for that matter) control, assign the external datasource datawindow object to it, insert a row, then populate the fields with data of the corresponding datatype.

Example usage:

datawindow ldw
long llrow
ldw = CREATE datawindow
ldw.dataobject = 'myExternalDatawindowObject'
llrow = ldw.insertrow(0)
ldw.setitem(llrow,'stringcolumn','my example string')
ldw.setitem(llrow,'numericcolumn',1234)
Matt Balent
  • 2,337
  • 2
  • 20
  • 23
  • Thank you, the correct method was SetItem(row, column, value) given the fact that you have accordingly declared the data type during DataWindow creation. – Panagis Loukatos Feb 19 '16 at 07:50
0

It's been a while since I used PowerBuilder, but IIRC you should be able to use a DataStore without having a database connection.

Slapout
  • 3,759
  • 5
  • 40
  • 61