Row count issue with datagrid tutorial

Hi Bridget,
How are you?

I find your explanation very interesting! and perhaps aligned in the right direction to solve a problem I have.
The case is as follows:
I started with: A data grid, with its repeating panel, with a DataRowPanel for each row, and reading perfectly from the database. So far. so good.
Then, in order to make it editable the tutorial I was following made me disable the autodisplay information for the default DataRowPanel, and instead create two other DataRowPanels, one for displaying and eventually deleting or editing, and one for editing and saving. (I also had to put labels and text boxes in those rows and bind them to the items)
The rowcount that worked perfectly when I only had the default DataRowPanel, well, stopped working fine.
Now it shows, … in fact I’m not sure of what it shows.
But my “row” in the repeatng panel now consists of 3 rows, the original, the view one (with the buttons for edit or delete), and the edit row with the editable fields and the save button.

It is obvious that I do not uderstanding how to use rowcount in this situation, and probablly it is because of the fact that I don’t understand the row structure of my repeating panel.
Could you please try to explain that to me? (that is in the case you understood my explanation of what I’ve done, basically the datagrid tutorial :slight_smile: )

Thank you very much! (and sorry for the messy explanation)
Warm regards!
Ricardo

Providing a clone link to show what you’re trying would help people understand what’s going on, and they’d be able to offer better advice.

I’m not sure it is what you are looking for:
if you put inside repeating panel row additional data rows they will counted together as single rows.
So if you set the Data Grid to show only 10 rows for each pagination and add additional data rows, it won’t be counted as 1. For example adding even a custom header row(data row panel at the top of repeating panel) will be counted as 1 row. So in order to show 10 rows per page it has to be set to 11.

Instead of counting the rows use len(self.repeating_panel_1.items) or use it on the list or database iterator that you will assign to the panel.

Hi KR,

I just have a text box in which I enter the number of lines per page I want the datagrid to display.
It was working fine until I modified the default repeating panel of the data grid, in order to make rows editable. (following the instructions of the Datagrid tutorial,(which I might have executed wrong)

As suggested by Jay, I’ll share a copy of the project so you can see it. I believe the problem is a combination of my newbieness and the lack or certain knowledge, plus something I might’ve done wrong in the UI.

Thank you very much!!!
Warm regards
Ricardo

Hi J,
Sure, my bad.
I’m doing it right now. (beware there are some Spanish words mixed in the UI and comments)

Thank you very much!!
Warm regards
Ricardo

P.S. Still getting used to best practices in intercting in the forum. :smiling_face:

If you use so many data row panels it gets messy.

How it is counted:
1st data row:


2nd data row:

So each of you page has always already 2 data rows.

Each of that row count for 2

If you write in your textbox 1-3 nothing will appear. First with number 4 you will see you headers and one row.
6 = 2 rows
12 = 10 rows.

so in order to trick it. You need to write a short code that manipulte the provided number to the correct one.

number_textbox * 2 (for repeating panel row) + 2 (for your headers)

2 Likes

Hi KR1,
Thank you very much for your answer!! It works.

I understand your explanation; it is completely clear; and I also agree that it is messy to have to use that many rows to emulate the CRUD functionality, and be forced to be counting the data rows inside each repetition of the repeating panel.
However, unless I really misinterpreted the instructions, this is how it is described to be done in the Datagrid tutorial.
So, I would really love to hear if there is a less messy/simple way to achieve this same functionalitty (because in fact I believe the Datagrid is meant for showing rows in a table, and not acting as a CRUD)
On the other hand a CRUD is probably the most common functionality in any system, so I would love to have an easier way to solve it.
Do you know of any?

That being said, I left open the possibility that I added Datarows instead of something else I should have added, or I added them in the wrong place, and then I caused the mess.

Thanks again!
Warm regards!!!
Ricardo

I like to look at a DataGrid as a tool designed to show a list of dictionaries.

Row objects behave like dictionaries, so you can show them, but this is the only link between database and DataGrid. It’s a coincidence more than a design intention.

You can do nothing, and the DataGrid will show unformatted text.
You can use a simple template, and the DataGrid will use the template to format or edit your data.
You can make your template as complex as you like, and the DataGrid will still work.

Most of my DataGrids are not really DataGrids, they are DataGridJsons, and show the simplest formatting.

Other DataGrids have complex templates with canvases to show a graphic representation of the data, with sub-DataGrids to show tree-like data, etc.

The bad thing is that the DataGrid doesn’t offer great functionalities out of the box.
The good thing is that you can make it as complex as you like.

You can even do CRUD with it! :slight_smile:

2 Likes

Hi Stefano,
A much more acccurate analysis of my statement. And it also decouples my misconception of datagrid=showtablecontent.
So basically what you display on the datagrid, and how, is a matter of choice and not design.
I’ll keep that in mind and try to recall it next time I use it.

Thank you!!

1 Like