cancel
Showing results for 
Search instead for 
Did you mean: 

Paging does not work within the sap:table

Former Member
0 Kudos

Hi,

When i try to select the next page in a table with several pages as a db query result, the same "page" of the table is rendered after the postback.

Do i miss s.th. ?

Do i have to implement the paging Event_Handler?

If so, please tell me how to accomplish.

Regards

Erhan

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Ofer,

thank you very much for reviewing my code, and telling me about the set firstVisibleRow. That was the problem

But what now occurs is the following:

When I have sorted the Table, and then select another table-page, the sorting is not maintained, allthough the column is marked as sorted. Do I have to save the ColIndex and the SortIndex in e.g. a ViewState? If so, how do I set this values after the postback raised by the paging event. Setting the ColIndex is accomplished easily, but how do I set the SortingDirectiion?

Thanks Erhan

Message was edited by: Erhan Tamer

Former Member
0 Kudos

Hi Erhan,

First - you're welcome... how about some points?

As for the sorting - Where is your sorting code located exactly? I think that what's wrong this time is that you call sort on your data source only when the event happens. Once post back happens (like in paging), this sorting is lost. you should also call it (according to what was saved in view state) in the page load (or on your onMyEvent maybe.

Regards,

Ofer

Former Member
0 Kudos

Hi Ofer,

this is the function I do call, after a postback and after the Table has been filled.

But this does not work. The Session Variables are filled correctly. Do you see anything going wrong?

private void sortTable()
        {
            if (Session["SortColumnTitle"] == null) return;
            
            IBindingList bl = tblErgebnis.DataSource as IBindingList;
            if (bl != null && bl.SupportsSorting && bl.Count > 0)
            {
                bl.ApplySort(TypeDescriptor.GetProperties(bl[0])[(string)Session["SortColumnTitle"]], (System.ComponentModel.ListSortDirection)Session["SortDirection"]);
                tempVar = 0;
            }

        }

Former Member
0 Kudos

I'm not sure exactly where you call this function,

but if it's after the table has been filled, than that explains why the sort doesn't work - it should be called before, since you aren't sorting the table, you are sorting the datasource...

Regards,

Ofer

Former Member
0 Kudos

Hi,

the VisibleRowCount of my table is set to 10.

When I fire the Paging Event NAVIGATEPAGENEXT for the first time, i do expect, that the data beginnig (firstVisibleRow=11) at 11 is shown. But the Data beginning with 1 is still shown. But at the bottom of the table, i do see the current page index "2".

When I click again the Next-Page-Button, the Data from 11-19 is shown , and the current page index is 3.

When i now click the Button First-Page, data from 20-29 is shown while the current page index is correctly 1.

Does anyone have a idea, why this mysterious things happen?

Thanks

Erhan

Former Member
0 Kudos

Hi,

is anyone here who can report a bug too of the sap:table control, concerning the paging?

If there is anyone who uses the paging event sucessfull, please give me some code .

I am still having the problem with paging.

When I click the "Next Page" Button of my page, a postback is fired. After the page has been rendered, i do see, correctly the digit "2" in the footer of the table, but the rows of the table do still contain the elements of page 1.

Thanks

Erhan

rima-sirich
Advisor
Advisor
0 Kudos

Hi Erhan,

Could you, please, tell me :

1. Which version of the PDK for .NET you use ? Is it PDK 2.0 or PDK 2.5 ?

2. Which version of the Portal you use ? Is it NW04 or NW04s ? Which SP ?

Regards,

Rima.

Former Member
0 Kudos

Hi Rima,

1. PDK for Visual Studio 2005 , so it must be 2.5 !

How do i determine point 2 ?

Thanks

Erhan

rima-sirich
Advisor
Advisor
0 Kudos

Hi Erhan,

1. Navigate to http://[host]:[port]/index.html

2. Click on System Information

3. In the table "Software Components" you see the version

Regards,

Rima.

Former Member
0 Kudos

Hi Rima,

its 6.40 SP11, but how do i see if it is nw04s or not?

The problem I do have must be a bug.

I did find a workaround for this:

In Tables paging_event:

1. Save the FirstVisibleRow in a Variable

2. Set the Tables FirstVisibleRow to the value the user has choosen

3. Make a DataBind to the table

4. set the Tables FirstVisibleRow to the Variable under 1.

The only problem is, that i didnot find a way to determine the directly entered page number, so this does not work.

Do you know how i can determine dynamically what page number the user entered to show?

Thanks

Erhan

rima-sirich
Advisor
Advisor
0 Kudos

Hi Erhan,

1. It means that you have NW04.

2. I agree with you, it seems to be a bug ... There is a possibility that fix for this bug will be included in the next release of the PDK that is coming soon In case it will, I'll update you.

3. The only solution I can think about is to use Table.FooterVisible = false in order to hide the paging panel and implement paging events with your own buttons playing with FirstVisibleRow. If it is not an urgent issue for you, I don't know if it worths to waste your time on it.

Regards,

Rima.

Former Member
0 Kudos

Hi Rima,

thank you very much for your assistance

You are right it is not worth to waste time on it.

Up to my last Post, I was not sure if it is a bug, or s.th. that i make wrong.

You say I do use NW04.

Which Portal Version stands for NW04s ?

Thanks and Regards

Erhan

rima-sirich
Advisor
Advisor
0 Kudos

Hi Erhan,

EP7 = NW04s.

Regards,

Rima.

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Ofer,

	private void Page_Load(object sender, System.EventArgs e)
		{
			foreach (Control c in Form.Controls)
			{
				IEventProducer iep = c as IEventProducer;
				if (iep != null)
					iep.MyEvent += new MyDelegate(<b>OnMyEvent</b>);
			}
....

An other iView raises the OnMyEvent:

public void OnMyEvent(object sender, ServerSideEventArgs args)
		{
			// Session["Source"]=dbops.giveDV(General.sql_stehendeWagons + " > 800 AND TT.FNR = 7502");
			// .FirstVisibleRow has to be set to 0, in order to achiev
			// that if a new query has to be assigned to the table, that the table
			// shows the first page presuming that the table contains more than 1 page
			// This property has to be set to 0 before the DataBind()
			//Label4.Text="OnMyEvent";
            tblErgebnis.Visible = true;	
            
            if (args.SQL_Statement!="")
			{
				
				if ((string)Session["Select_Statement"]!="")
			{
				this.tblErgebnis.FirstVisibleRow=0;
				
				
                // The table is filled here by using   
				// sapTable.DataSource = Dbops.giveDataView(strStatement);
				// sapTable.DataBind();
				UIPComponents.fillControl(ref tblErgebnis, args.SQL_Statement); 
				
				// Changing the ColumnNames in the DataView
				setC(); 
				
				// Mapping the Columnnames for sorting
                setColumnNames(); 
				tblErgebnis.Visible=true;
			}
			}
	}

Regards

Erhan

Former Member
0 Kudos

Hi Erhan,

I might be missing something, but it seems like you have to raise the event in order to fill the table. When paging happens, the table is expected to be filled already in the Page_Load, which isn't the case.

You can add code to your page load to raise this event again in case of "IsPostBack"... or something of the sort.

You can also try to do it in the paging event (though that might be too late, I'm not sure).

Regards,

Ofer

Former Member
0 Kudos

Hi Ofer,

the event is raised by another iView, and when the paging event occurs (steps into the paging event), the table is already filled.

So when I have clicked, for example Page 2 for the table, while 100 pages are existing, after the postback page 1 is shown again.

Sorting does work without any problems.

So I do miss s.th. like, "show the choosen page content"

Thanks

Erhan

Message was edited by: Erhan Tamer

Former Member
0 Kudos

If I look at you code (not sure I understand or see all of it), it seems like the only place where you actualy fill the table (OnMyEvent), you also set the first visible row to 0... which will of course prevent the paging from working. Try using an "if" there...

Regards,

Ofer

Former Member
0 Kudos

Hi Ofer,

<sap:Table visible="false" id="tblErgebnis"  AutoGenerateColumns="True" runat="server" VisibleRowCount="10"
		FillUpEmptyRows="true" FirstVisibleRow="1"  SelectionMode="NONE">
		<sap:Caption ID="caption1"></sap:Caption>
		<sap:TableRow ID="tblErgebnis_ItemTemplate">
			<sap:TableCell ID="tblErgebnis_Column1" SortState="NONE" Title="Column1">
				<sap:TextView ID="textView1" Text='<%# DataBinder.Eval(Container.Parent,"DataSourceRow.DataItem.Column1") %>'>
				</sap:TextView>
			</sap:TableCell>
			<sap:TableCell ID="tblErgebnis_Column2" SortState="NONE" Title="Column2">
				<sap:TextView ID="textView2" Text='<%# DataBinder.Eval(Container.Parent, "DataSourceRow.DataItem.Column2") %>'>
				</sap:TextView>
			</sap:TableCell>
		</sap:TableRow>
		</sap:Table>

The Table is filled dynamically in the codebehind.

While the sorting of the table does work, the paging does not. I do see the paging elements at the bottom of the table, but selecting has no visible effect.

For sorting I do need to use the following code:

 try
            {
                if (tempVar == 1)
                {
                    IBindingList bl = e.DataSource as IBindingList;
                    if (bl != null && bl.SupportsSorting && bl.Count > 0)
                        bl.ApplySort(TypeDescriptor.GetProperties(bl[0])[e.SortColumn.Title], e.SortDirection);
                }
            }
            catch
            { }

Is there any code to be used for paging?

Thanks

Erhan

Former Member
0 Kudos

Hi Erhan,

Normally you don't need special code for paging.

Can you also post your table-filling code (in context - where it's located)?

Regards,

Ofer

Former Member
0 Kudos

Hi Erhan,

Maybe if you post your code someone might see the problem...

Regards,

Ofer

Former Member
0 Kudos

Is nobody there who can help?