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 )
Thank you very much! (and sorry for the messy explanation)
Warm regards!
Ricardo
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.
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.
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.
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.
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.