Show Row Number on Position and count value

Hello,

i trying many hours. but it doesnt work. So i hope i can get help.

I want make a Datagrid with showing the row number. (Position) automatic. 

AllowRowDragAndDrop="true" is true. so i move the 2. row to 1. The Position number must reorder. so beginning from 1 to x 

Position | Order ID | Name

1    | 1234

2    |4563


And my second problem ist. I have 2 values to enter. for example  hours and price. 

so i enter 2 hours and price 20, so would show in the 3 colum the count = 40 for every row!

thank you for support...

Best Regards

Serkan

 


1 Reply

RS Renjith Singh Rajendran Syncfusion Team January 3, 2022 12:11 PM UTC

Hi Serkan, 
 
Greetings from Syncfusion support. 
 
Query 1 : I want make a Datagrid with showing the row number. (Position) automatic. 
We have prepared a sample based on this requirement for your convenience, please download and refer the sample from the link below, 
 
You can display position number in Grid’s column using the Column Template feature of Grid. With this you can fetch the corresponding position number based on your custom calculations and display the calculated row position number using column template feature of grid. Please refer the codes below. We have performed calculation inside a custom method(GetRowCounter) and returned the calculated result to display using column template. 
 
 
<GridColumn HeaderText="S.No"> 
    <Template> 
        @{ 
            var con = (context as Order); 
            var Index = GetRowCounter(con.OrderID); 
        } 
        <span>@(Index.Result)</span> 
    </Template> 
</GridColumn> 
 
public async Task<double> GetRowCounter(int? val){    var index = await Grid.GetRowIndexByPrimaryKeyAsync(val);  //fetch rowindex based on primary key    var currentPage = Grid.PageSettings.CurrentPage;    if (Grid.AllowPaging && currentPage > 1)    {        index = (((currentPage - 1) * Grid.PageSettings.PageSize) + index);    }    return index + 1;}
 
 
References :  
 
Query 2 : And my second problem ist. I have 2 values to enter. for example  hours and price. so i enter 2 hours and price 20, so would show in the 3 colum the count = 40 for every row! 
We have discussed a similar query in the below thread, please refer the below thread for more details regarding this query. 
 
Kindly refer the above thread and if you are facing any difficulties or if we have misunderstood your requirement then kindly share with us the details regarding the EditMode you are using in Grid to proceed further based on your scenario. 
 
Regards, 
Renjith R 


Loader.
Up arrow icon