React Component in Grid Column

Hello everyone, I'm working on a React Redux application.I'm having difficulties finding a way render my React Component in every row of a particular column in ej2-react-grids. The only way that I have found is to put my component into column template script, but then OnChange event won't fire.
What is the proper way of doing this? Thanks!

5 Replies

RU Ramdhas  Ueikattan Syncfusion Team October 19, 2017 01:26 PM UTC

Hi Marko Cuca, 

Event handler for the dropdown change can be add on the window. This will be fire on every drop down change done. Please refer the below code snippet. 


. . .  
<GridComponent allowPaging={true} pageSettings={{pageSize:8}} dataSource={data}> 
          <ColumnsDirective> 
            <ColumnDirective field='OrderID' headerText='Order ID'></ColumnDirective> 
            <ColumnDirective field='CustomerID' headerText='Customer ID'></ColumnDirective> 
            <ColumnDirective field='OrderDate' textAlign='right' format='yMd'></ColumnDirective> 
            <ColumnDirective field='ShipCountry' headerText='Ship Country'></ColumnDirective> 
            <ColumnDirective headerText='Template' template={`<div><select onchange='onChange()'><option> Select </option><option> DeSelect </option></select></div>`} > 
            </ColumnDirective> 
          </ColumnsDirective> 
          <Inject services={[Page]} /> 
        </GridComponent> 
. . . 

// Handler for drop down bind on window object. 

window.onChange = () =>{ 
  console.log(document.activeElement.value);  //Onchange event handler fires every drop down changes. 
} 

  

Regards, 
Ramdhas  Ueikattan. 



UN Unknown Syncfusion Team October 20, 2017 06:46 AM UTC

Thanks Ramdhas, exactly what I needed. 



RU Ramdhas  Ueikattan Syncfusion Team October 23, 2017 09:17 AM UTC

  
Hi Marko, 
  
We are glad to know that given solution works. Please let us know if you need any further assistance. 
  
Regards, 
Ramdhas  Ueikattan 



IN imam nawawi November 5, 2018 02:14 PM UTC

if i want to use comoponent in the tempalte={}
how can i do ?

because the template just can read html script, i try with <a> and <div> its working.

but when i used <ButtonComponent/> its not working


MF Mohammed Farook J Syncfusion Team November 6, 2018 04:09 AM UTC

  
Hi Marko,  
 
By default, onChange event is not working button component.  You can use onClick event for button event. This is not meet your requirement please share the following details 
  1. do you have render select tag inside of button?
  2. Please share the full grid code example.
Regards, 
J Mohammed Farook 


Loader.
Up arrow icon