BlazorTable icon indicating copy to clipboard operation
BlazorTable copied to clipboard

How to do Auto Increment Number in first column?

Open citsole opened this issue 3 years ago • 2 comments

Dear Sir Please help me how to do auto increment number in first column, mean not selected from ID in database. Thank you

citsole avatar Nov 29 '20 15:11 citsole

Is there a way to actually do this? As in, have a column with a row number that counts up starting from 1, regardless of filters and sorting?

rbergen avatar Jun 20 '21 20:06 rbergen

To answer my own question: yes, it is. This is the code setup that I used at the beginning of the table definition:

<Table Items="results" @ref="resultTable">
	@{ rowNumber = resultTable.PageNumber * resultTable.PageSize; }
	<Column TableItem="Result" Title="#" Sortable="false" Filterable="false">
		<Template>
			@(++rowNumber)
		</Template>
	</Column>
...

...with rowNumber being defined as an int in the page's @code block.

Do note that the numbering does not factor in filtering and/or sorting, but does consider pagination.

rbergen avatar Jun 21 '21 15:06 rbergen