cancel
Showing results for 
Search instead for 
Did you mean: 

Table grows when I clear it

Former Member
0 Kudos

Hi,

I am having a strange problem with my table

I have set the VisibleRowCount of my table to be 5

I put 30 items in it

It shows 5 rows with the footer showing 6 pages

I go to the last page

all fine so far

I call Clear() on the table

now it shows 30 rows (all with empty cells)

As I click the page up arrow it removes five rows

If I click the go to start arrow it returns to normal size

If I haven't gone down a page in the table when I clear it also behaves as normal

or if after calling clear I then insert new rows it works fine

So the problem only occurs with the following sequence

Insert data

Go to last page

clear data

Is this a bug in the control?

Has anyone seen it before?

Vin

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi again Vincent,

One clarification first -

The SAP NetWeaver control Table is actualy much more like a MS DataGrid than the MS Table. It's specialized in data binding much more than manual adding of data (though it supports it). It's called "Table" because that is the SAP name (in other SAP technologies, like Web Dynpro, Htmlb) for such a control.

Now - as to your problem - you probably should try to set the table's FirstVisibleRow to 0 when you do a Clear.

Regards,

Ofer

Former Member
0 Kudos

That was the problem

Thanks Ofer

Answers (2)

Answers (2)

Former Member
0 Kudos

EDIT: I seen your reply after posting.

Have you considered using the DataGrid or DataList controls to display the data in columnar fashion? It's a lot easier to manage the display and source with those controls. If you change the source, you will just have to rebind the control to the data again.

<originalPost>I'm assuming you are using the DataGrid. Are you binding to the source data again after calling the clear method? For the most part, every time you do a post (page change event, sort event, etc.), you will need to rebind to the source else it will take the data from ViewState, which might or might not be in a state you want it to be in.</originalPost>

Message was edited by: Hithesh Ranchhod

Former Member
0 Kudos

I'm not binding at all

I am manually adding all my data in so there is no source as such (there is obviously a source but it isn't a standard datasource so I can't bind to it)

The main reason I used the Table is because it makes the component look like a SAP component

The DataGrid is really designed for binding even more than the Table is so I figured it'd be more hassle to maually add and update the data.

Vin

Former Member
0 Kudos

I was trying to figure out which control you are using as the standard server Table control does not have the VisibleRowCount attribute but it is in the PDK table control (i think you are using this?). I have no experience in the PDK controls.

Former Member
0 Kudos

Sorry about the confudion

I am using the PDK table, I should have been clearer on that!

Former Member
0 Kudos

just as a bit of extra information.

Here is a sample project the reproduces the behaviour every time on my machine

You need to add 3 buttons (btnFill, btnClear, btnClearAndFill) to the component and a Table (tblTest)

and here is the code in the cs file for it

using System;

using System.Collections;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Web;

using System.Web.UI;

using SAP.Portal.Web.UI;

using SAP.UI;

using SAP.Web.UI.Controls;

namespace TableTest

{

public class PortalComponent1 : SAP.Portal.Web.UI.PortalComponent

{

protected SAP.Web.UI.Controls.Button btnClear;

protected SAP.Web.UI.Controls.Button btnClearAndFill;

protected SAP.Web.UI.Controls.Table tblTest;

protected SAP.Web.UI.Controls.Caption caption1;

protected SAP.Web.UI.Controls.TableRow tblTest_ItemTemplate;

protected SAP.Web.UI.Controls.TableCell tableCell1;

protected SAP.Web.UI.Controls.TextView textView1;

protected SAP.Web.UI.Controls.TableCell tableCell2;

protected SAP.Web.UI.Controls.TextView textView2;

protected SAP.Web.UI.Controls.TableCell tableCell3;

protected SAP.Web.UI.Controls.TextView textView3;

protected SAP.Web.UI.Controls.Button btnFill;

private void Page_Load(object sender, System.EventArgs e)

{

if (Session["Init"] == null)

{

Session["Init"] = false;

Session["ClearAndFill"] = false;

Session["Fill"] = false;

Session["Clear"] = false;

}

if ((bool)Session["Fill"] == true)

{

Fill();

}

else if ((bool)Session["ClearAndFill"] == true)

{

Clear();

Fill();

}

else if ((bool)Session["Clear"] == true)

{

Clear();

}

}

#region Web Form Designer generated code

protected override void OnInit(EventArgs e)

{

//

// CODEGEN: This call is required by the ASP.NET Web Form Designer.

//

InitializeComponent();

base.OnInit (e);

}

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.btnFill.Action += new SAP.Web.UI.Controls.AbstractButton.ActionEventHandler(this.btnFill_Action);

this.btnClear.Action += new SAP.Web.UI.Controls.AbstractButton.ActionEventHandler(this.btnClear_Action);

this.btnClearAndFill.Action += new SAP.Web.UI.Controls.AbstractButton.ActionEventHandler(this.btnClearAndFill_Action);

this.Load += new System.EventHandler(this.Page_Load);

}

#endregion

private void btnFill_Action(object sender, SAP.Web.UI.Controls.AbstractButton.ActionEventArgs e)

{

Session["ClearAndFill"] = false;

Session["Fill"] = true;

Session["Clear"] = false;

Fill();

}

private void Fill()

{

for (int i = 0; i < 30; ++i)

{

TableRow tr = new TableRow();

TableBodyCell c1 = new TableBodyCell(tblTest, tr, 0);

c1.TableCellContent = new TextView(i.ToString());

tr.Cells.Add(c1);

TableBodyCell c2 = new TableBodyCell(tblTest, tr, 1);

c2.TableCellContent = new TextView(i.ToString());

tr.Cells.Add(c2);

TableBodyCell c3 = new TableBodyCell(tblTest, tr, 1);

c3.TableCellContent = new TextView(i.ToString());

tr.Cells.Add(c3);

tr.Key = i.ToString();

tblTest.Items.Add(tr);

}

}

private void btnClear_Action(object sender, SAP.Web.UI.Controls.AbstractButton.ActionEventArgs e)

{

Session["ClearAndFill"] = false;

Session["Fill"] = false;

Session["Clear"] = true;

Clear();

}

private void Clear()

{

tblTest.Items.Clear();

}

private void btnClearAndFill_Action(object sender, SAP.Web.UI.Controls.AbstractButton.ActionEventArgs e)

{

Session["ClearAndFill"] = true;

Session["Fill"] = false;

Session["Clear"] = false;

Clear();

Fill();

}

}

}