cancel
Showing results for 
Search instead for 
Did you mean: 

Attaching table to a button press, Form contains buttons & click on button a table should come inside same form

RaghavRathor
Explorer
0 Kudos

Hi Experts,

My requirement is  i have one form, inside that form i have three buttons, after clicking each button a table should come up inside the same form & for each button the values are different.

I have created one form, a table, and a model, i have defined some data which is bind to the model, now my question is

1. How to get the table on button click????

2. I have to define three different models, tables for each button????

please share yours views its urgent

Thanks

Raghav Rathor

Accepted Solutions (1)

Accepted Solutions (1)

surendra_pamidi
Contributor
0 Kudos

Hi Raghav,

If you set the model to the table inside the button press function, you will get the table after button click only.

If you are using json model, then no need to create three models. Just create one model. Set the json to that model.

You have two options.

1.After every button click, you have to get a different json. So that totally you will get three json. Set the json to model and set the model to table after every button click.

2.Create 3 json , 3 models and one table. After every button click set the required model to the same table.

First one is better if you are using different data json every time.

Second one is better if you are using same 3 json data repeatedly.

RaghavRathor
Explorer
0 Kudos

Hi Surendra,

Thanks for your reply, your suggestions are really helpful, i have one more question can you please tell me how to set the model to the table inside the button press function, i am not able to write the code for this.

Thanks

Raghav Rathor

surendra_pamidi
Contributor
0 Kudos

Hi Raghav,

oButton.attachPress(function(){

oTable.setModel(oModel);

};

Regards,

Surendra.

RaghavRathor
Explorer
0 Kudos

Hi Surendra,

Thanks Button press is working fine, but now i am facing another issue with table, i have added three button & a table inside a form, first time when the page loads three buttons & a empty table appears,

after clicking on first button the table appears which i had added through json model.

But the problem comes with second & third buttons, if i am adding some columns  in the same first table these columns also reflecting with first button & not working with second button

1. So i have to create three different tables????& attach these tables to the form, but the problem with this is, when the page loads it will load all the three tables

Thanks

surendra_pamidi
Contributor
0 Kudos

Hi Raghav,

No need to create three tables. Just set the model as I shown.. with the related json file .

I think you are not adding second json to the second model on click on the second button .

RaghavRathor
Explorer
0 Kudos

Hi Surendra,

Thanks for your time, now the problem is button click is working fine for all the three buttons and data is also coming properly, but i have different columns for each button but the table shows columns for every button, means for first button i have two columns & for third button i have 5 columns,

but for third button the table is showing columns for 1st button also.

I need specific columns for each table, could you please help on this

Thanks for button press function

Raghav

RaghavRathor
Explorer
0 Kudos

Hi Surendra,

One more requirement i have each table contain one more button add, on clicking on add button

a box have to be displayed with some text field, so how to integrate that button with each table 

surendra_pamidi
Contributor
0 Kudos

After adding third button columns to table, remove the columns of previous button. Then you will get only that button columns only.

Use removeColumn(); to do that...

surendra_pamidi
Contributor
0 Kudos

var oTable = new sap.ui.table.Table({

title: "Table Example",

visibleRowCount: 7,

firstVisibleRow: 3,

selectionMode: sap.ui.table.SelectionMode.Single,

toolbar: new sap.ui.commons.Toolbar({items: [

new sap.ui.commons.Button({text: "Button in the Toolbar", press: function() { alert("Button pressed!"); }})

]}),

extension: [

new sap.ui.commons.Button({text: "Button in the Extension Area", press: function() { alert("Button pressed!"); }})

]

});

Check this......

SAPUI5 SDK - Demo Kit

RaghavRathor
Explorer
0 Kudos

Hi Surendra,

Thanks for replying me & giving me your valuable time, as i am moving forward i am facing many problems, the first one is --> how to destroy the created column, there is one method call "destroyColumns()" but i don't know how to use this function.


If i added one column like

So how to destroy it

table.addColumn(new sap.ui.table.Column({

  label: new sap.ui.commons.Label({

  text:"CKey"

  }),

  template: new sap.ui.commons.TextField().bindProperty("value",

  "CKey"),

  }));

One more think is there, i need a add button below each table, & when i click the button a dialog box should come with some controls, & i have three different tables(means table is single but the column changes every time ) So where i have to declare this add button, within the table or inside the button press which i am using for populating the table ???????

Could you please tell me the code for Dialog box attach to button press, I tried but it is showing error

Duplicate id for elements some think like that.

Thanks in advance

Raghav Rathor

surendra_pamidi
Contributor
0 Kudos

Hi Raghav,

Duplicate id error because of you are creating same control with the same id again and again..

Use table extend to add button,if you need the button within the table.

Don't create inside the button press function. Create dialog box outside and open it inside and close when you want to close.

syntax is dialogbox.open();

              dialogbox.close();

Answers (0)