We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Show rowheader with number

Hi,
is it possible to show a rowheader in a grid?

Kind regards,
michael

7 Replies

PS Pavithra Subramaniyam Syncfusion Team September 26, 2019 07:16 AM UTC

Hi Michael, 
 
Greetings from Syncfusion support. 
 
From your query we understood that you want to show the number for each row in Grid. If so you can achieve your requirement by using the column template. Please refer to the below code example, documentation link and sample link for more information. 
 
In the below sample we have added the row index as row header in each row. 
 
[index.cshtml] 
<template> 
  <div id="app"> 
    <ejs-grid 
      id="Grid" 
      ref="grid" 
      :rowDataBound="rowDataBound" 
      :dataSource="data" 
      :allowPaging="true" 
    > 
      <e-columns> 
       // if you have the rowheader value in dataSource then you can set by adding <span>${fieldName}</span> 
        <e-column width="80" headerText="S.NO" template="<span></span"></e-column> 
        <e-column field="OrderID" headerText="Order ID" width="90"></e-column> 
        <e-column field="Freight" headerText="Freight" format="C2" width="90"></e-column> 
      </e-columns> 
    </ejs-grid> 
  </div> 
</template> 
 
<script> 
.    .   . 
  methods: { 
    rowDataBound: function(e) { 
      var data = this.$refs.grid.ej2Instances.getRowObjectFromUID( 
        e.row.getAttribute("data-uid"); // getting the row details 
      ); 
      e.row.getElementsByTagName("span")[0].innerText = data.index; 
    } 
  } 
}; 
</script> 



 
 
 
 
 Sample              : https://codesandbox.io/s/vue-template-zt1v0 

Please get back to us if you need any further assistance on this. 
 
Regards, 
Pavithra S. 



MK Michael Kornatzki September 26, 2019 10:35 AM UTC

Thank you.


PS Pavithra Subramaniyam Syncfusion Team September 26, 2019 11:35 AM UTC

Hi Michael, 
 
Thanks for your update. 
 
Please get back to us if you need any further assistance on this. 
 
Regards, 
Pavithra S. 



MK Michael Kornatzki October 7, 2019 10:58 AM UTC

Hi,

after the test with numbered rowHeader works i try to make the column fixed.
In my example i have 9 rows (frozenColumns=0) and if i use a fixedColumn (frozenColumns=1) then i get zero rows and the grid is corrupt!

Kind regards,
Michael

frozenColumn=0

frozenColumn=1


Attachment: App_f9f068dd.zip


PS Pavithra Subramaniyam Syncfusion Team October 8, 2019 10:40 AM UTC

Hi Michael, 
Thanks for your update. 
You can achieve your requirement by using queryCellInfo event. 
Please refer to the below code example and sample. 
 
<ejs-grid 
     :queryCellInfo="queryCellInfo" 
     :dataSource="data" 
     :frozenRows="rows" 
     :frozenColumns="columns" 
. . .   > 
      <e-columns> 
        <e-column width="80" headerText="S.NO" template="<span></span"></e-column> 
. . . 
      </e-columns> 
</ejs-grid> 
 
export default { 
  data() { 
    return { 
      data: data, 
      rows: 2, 
      columns: 1 
    }; 
  }, 
  provide: { 
    grid: [Page, Freeze] 
  }, 
  methods: { 
    queryCellInfo: function(e) { 
      if (e.column.headerText === "S.NO") 
        e.cell.getElementsByTagName("span")[0].innerText = e.cell.getAttribute( 
          "index" 
        ); 
    } 
 
 
 
Regards, 
Pavithra S. 



MK Michael Kornatzki October 8, 2019 11:45 AM UTC

Thanks, it works :)


PS Pavithra Subramaniyam Syncfusion Team October 8, 2019 12:11 PM UTC

Hi Michael, 

Thanks for your update. 

We are happy to hear that the provided solution is working. 

Please get back to us if you need any further assistance on this. 

Regards, 
Pavithra S. 


Loader.
Up arrow icon