Skip to Content
author's profile photo Former Member
Former Member

Table grows when I clear it

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 21, 2004 at 08:06 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 20, 2004 at 03:06 PM

    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();

    }

    }

    }

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 20, 2004 at 06:55 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.