Fetching data by renderer in ag-grid using reactjs - reactjs

I am doing a project in ag-grid and using renderer to render selected gender from it. But, I am not able to fetch the data back. Actually, I have to get the value selected in the dropdown, I tried a lot but I am not able to get it. Please can someone help me with this? At least can I get a hint
App.js
class App extends Component {
constructor(props) {
super(props);
this.state = {
columnDefs: [
{ headerName: "Id", field: "Id", width: 120, checkboxSelection: true, sortable: true, filter: true, editable: true, resizable: true },
{ headerName: "Name", field: "Name", width: 140, sortable: true, filter: true, editable: true, resizable: true },
{ headerName: "Email", field: "Email", width: 200, sortable: true, filter: true, editable: true, resizable: true },
{ headerName: "Gender", field: "Gender", cellRenderer: 'genderRenderer', cellRendererParams: { onGenderChange: this.onGenderChange }, width: 140, sortable: true, filter: true, resizable: true },
{ headerName: "DOB", field: "DOB", cellRenderer: 'dateRenderer', cellRendererParams: { onDateChange: this.onDateChange }, width: 160, sortable: true, filter: true, editable: true, resizable: true },
{ headerName: "Country", field: "Country", cellRenderer: 'countryRenderer', cellRendererParams: { onCountryChange: this.onCountryChange }, width: 140, sortable: true, filter: true, resizable: true },
{ headerName: "City", field: "City", cellRenderer: 'cityRenderer', cellRendererParams: { onCityChange: this.onCityChange }, width: 140, sortable: true, filter: true, resizable: true },
{ headerName: " ", field: "Delete", cellRenderer: 'deleteRenderer' }
],
rowData: [
{ 'Id': '1', 'Name': "kishor", 'Email': "kishor#gmail.com", 'Gender': "", 'DOB': "", 'Country': "", 'City': "" },
],
suppressAggFuncInHeader: true,
frameworkComponents: {
genderRenderer: GenderRenderer,
}
this.onGenderChange = this.onGenderChange.bind(this)
}
onGenderChange = (setGender) => {
console.log("Gender Change", setGender)
}
GenderRenderer.js
import React, {useState} from 'react';
function GenderRenderer(props) {
const[gender, setGender] = useState(props.value);
const onGenderChange = (event) => {
props.onGenderChange(event.target.value);
setGender(event.target.value);
}
return(
<div>
<select name="select" value={gender} onChange={onGenderChange}>
<option value="male"> Male </option>
<option value="female"> Female </option>
</select>
</div>
)
}
export default GenderRenderer;

Related

Unique id property could not be found from Material-UI Datagrid

Error: Material-UI: The data grid component requires all rows to have a unique id property. I am seeing when I call the table.
Here is my code. I know that the _turbineId field is unique in the dataset.
Here is how I have the table defined.
const columns = [
{
field: "siteName",
headerName: "Wind Farm",
width: 150,
editable: true,
},
{
field: "turbineName",
headerName: "Turbine Name",
width: 150,
editable: true,
},
{
field: "controller",
headerName: "Controller Type",
type: "number",
width: 110,
editable: true,
},
{
field: "swVersion",
headerName: "Software Version",
type: "number",
width: 110,
editable: true,
},
{
field: "location",
headerName: "Country",
type: "number",
width: 110,
editable: true,
},
{
field: "_turbineId",
headerName: "Turbine Name",
type: "number",
width: 110,
},
];
Here is how I define the rows
const rows = windFarmData.map((data) => [
{
siteName: data.SiteName,
turbineName: data.TurbineName,
controller: data.Controller,
swVersion: data.SoftwareVersion,
location: data.Country,
_turbineId: data.TechnicalId,
},
]);
Here is the datagrid
export default function DataTable() {
return (
<div style={{ height: 400, width: "100%" }}>
<DataGrid
getRowId={(r) => r._turbineId}
rows={rows}
columns={columns}
pageSize={5}
checkboxSelection
disableSelectionOnClick
/>
</div>
);
}
I wonder if I have missed something or done something wrong.
It works now. I replaced this:
const rows = windFarmData.map((data) => [
{
siteName: data.SiteName,
turbineName: data.TurbineName,
controller: data.Controller,
swVersion: data.SoftwareVersion,
location: data.Country,
_turbineId: data.TechnicalId,
},
]);
with this:
const rows = sortWindFarmData;

extjs 3.3 grid grouping and sum

I want to write the sums of some data under grouping and grid. I am sharing my codes, I will be glad if you help. Thank you.
var store = new Ext.data.JsonStore({
url: 'ajaxQueryData?_qid=4146',
root: 'data',
totalProperty: 'browseInfo.totalCount',
remoteSort: true,
id: 'sira_no',
sortInfo: {
field: 'sira_no',
direction: 'ASC'
},
fields: [
{
name: "sira_no",
type: "int"
},
{
name: "branch_id_qw_"
},
{
name: "firma"
},
{
name: "sevk_adres"
},
{
name: "malzeme"
},
{
name: "group_id_qw_"
},
{
name: "kategori_id_qw_"
},
{
name: "alt_kategori_id_qw_"
},
{
name: "vade"
},
{
name: "birim_tip_qw_"
},
{
name: "miktar"
},
{
name: "kg"
},
{
name: "birim_fiyat"
},
{
name: "para_birim_qw_"
},
{
name: "net_tutar"
},
{
name: "irsaliye_dt"
},
{
name: "irsaliye_no"
},
{
name: "fatura_dt"
},
{
name: "fatura_no"
},
{
name: "sehir_id_qw_"
},
{
name: "ilce_id_qw_"
},
{
name: "satis_sorumlusu_id_qw_"
}
],
pageSize: 50,
autoLoad: {
params: {
startRow: 0,
fetchCount: 50
}
}
// proxy: new Ext.data.HttpProxy({
// })
});
var grid = new Ext.grid.GridPanel({
store: store,
columns: [{
id: 'sira_no',
header: 'Sıra No',
width: 50,
sortable: true,
dataIndex: 'sira_no'
},
{
header: 'Şube',
width: 150,
sortable: true,
dataIndex: 'branch_id_qw_'
},
{
header: 'Firma',
width: 250,
sortable: true,
dataIndex: 'firma'
},
{
header: 'Sevk Adresi',
width: 150,
sortable: true,
hidden: true,
dataIndex: 'sevk_adres'
},
{
header: 'Malzeme Adı',
width: 200,
sortable: true,
hidden: true,
dataIndex: 'malzeme'
},
{
header: 'Grup',
width: 100,
sortable: true,
dataIndex: 'group_id_qw_'
},
{
header: 'Kategori',
width: 100,
sortable: true,
dataIndex: 'kategori_id_qw_'
},
{
header: 'Alt Kategori',
width: 100,
sortable: true,
dataIndex: 'alt_kategori_id_qw_'
},
{
header: 'Vade (gün)',
width: 80,
sortable: true,
dataIndex: 'vade'
},
{
header: 'Birim',
width: 50,
sortable: true,
hidden: true,
dataIndex: 'birim_tip_qw_'
},
{
header: 'Miktar',
width: 80,
sortable: true,
hidden: true,
dataIndex: 'miktar'
},
{
header: 'Kg',
width: 80,
sortable: true,
dataIndex: 'kg'
},
{
header: 'Birim Fiyat',
width: 80,
sortable: true,
dataIndex: 'birim_fiyat'
},
{
header: 'Para Birimi',
width: 50,
sortable: true,
dataIndex: 'para_birim_qw_'
},
{
header: 'Net Tutar',
width: 80,
sortable: true,
dataIndex: 'net_tutar'
},
{
header: 'İrsaliye Tarihi',
width: 100,
sortable: true,
hidden: true,
dataIndex: 'irsaliye_dt'
},
{
header: 'İrsaliye No',
width: 100,
sortable: true,
hidden: true,
dataIndex: 'irsaliye_no'
},
{
header: 'Fatura Tarihi',
width: 100,
sortable: true,
hidden: true,
dataIndex: 'fatura_dt'
},
{
header: 'Fatura No',
width: 100,
sortable: true,
hidden: true,
dataIndex: 'fatura_no'
},
{
header: 'Şehir',
width: 120,
sortable: true,
dataIndex: 'sehir_id_qw_'
},
{
header: 'İlçe',
width: 120,
sortable: true,
dataIndex: 'ilce_id_qw_'
},
{
header: 'Satış Sorumlusu',
width: 200,
sortable: true,
dataIndex: 'satis_sorumlusu_id_qw_'
}
],
viewConfig: {
forcefit: true
},
//resizable: true,
width: function() {
$("#aciklama").width();
$(document).ready(function() {
$(".slide-left").click(function() {
Width: $("#aciklama").width();
})
$(".slide-right").click(function() {
Width: $("#aciklama").width() - 334;
})
})
},
height: $("#aciklama").height(),
frame: true,
tbar: new Ext.PagingToolbar({
pageSize: 50,
store: store,
displayInfo: true
})
});
grid.render('aciklama');

A button on each row of Kendo ui Grid that expands detail view

I am using angular and Kendo ui Grid. I have a custom button on each row which i need it bound to a function that expand the detail view. Below is the grid options.
Please help
$scope.mainGridOptions = {
dataSource: financialYearsDataSource(),
sortable: true,
selectable: true,
columnMenu: true,
columns: [
{ field: "FinYearName", title: "Year Name", width: "150px" },
{field: "StartDate", title: "*Start Date", type: "date", format: "{0:dd-MM-yyyy}", width: "150px"},
{field: "EndDate", title: "*End Date", type: "date", format: "{0:dd-MM-yyyy}", width: "150px"},
{field: "Remarks", title: "*Remarks", editor: descriptionEditor, hidden:true},
{
command: [
{name: "edit"},
{name: "destroy"},
{
text: " Expand/Collapse",
click: $scope.expandToggle,
className: "fa fa-map-marker"
},
], title: " ", width: "300px"
}],
editable: {
mode: "popup"
},
pageable: {
pageable: true,
refresh: true
},
detailExpand: function (e) {
this.collapseRow(this.tbody.find(' > tr.k-master-row').not(e.masterRow));
}
};
Here is the toggle function that needs to do the toggling
$scope.expandToggle = function (e) {
e.preventDefault();
$scope.myGrid.expandRow($(this));
var dataItem = this.dataItem($(e.currentTarget).closest("tr"));}
Here is a jsfiddle demo:http://jsfiddle.net/akimaina/ay3vv2cm/2/
I have updated your fiddle. Please check if this solves.
http://jsfiddle.net/ay3vv2cm/3/
$("#grid").on("click",".clsExpand", function(e){
$("#grid").data("kendoGrid").expandRow($(e.currentTarget).closest("tr"));
});

how can i set extjs column in a function?

I have an EditorGridPanel which includes some columns but i want to change its type one of them to editor according to some values.
My column is below:
header: dil('Fiyat'),
width: 30,
sortable: true,
renderer: Ext.util.Format.numberRenderer('$0.000,00/i'),
dataIndex: 'fiyat'
but after changes, i want to work like:
header: dil('Fiyat'),
width: 30,
sortable: true,
renderer: Ext.util.Format.numberRenderer('$0.000,00/i'),
dataIndex: 'fiyat'
editor: new Ext.form.NumberField({
enableKeyEvents : true,
allowBlank: false,
allowNegative: false,
style: 'text-align:left'
})
My entire code:
var po_combolu_toolbar2 = new Ext.Toolbar({
items: [
new Ext.form.ComboBox({
id: 'po_combo_id',
hiddenName: 'po_combo_hid',
name: 'po_combo_name',
store: PoTipStore,
valueField: 'id',
displayField: 'isim',
typeAhead: true,
triggerAction: 'all',
emptyText: dil('Tip Seçiniz'),
selectOnFocus: true,
anchor: '100%',
listeners: {
select: {
fn: function (combo, value) {
var modelCmp = Ext.getCmp('po_combo_id').getValue();
po_siparis_grid.store.setBaseParam("secim", modelCmp);
if (Ext.getCmp('po_combo_id').getValue() == 5) {
} else {
}
po_siparis_grid.store.load();
}
}
},
allowBlank: true
})]
});
var po_siparis_grid = new xg.EditorGridPanel({
sm: new Ext.grid.RowSelectionModel({
singleSelect: true
}),
ds: new Ext.data.GroupingStore({
reader: po_siparis_reader,
writer: po_siparis_writer,
autoSave: false,
baseParams: {
type: 'POSiparis'
},
proxy: new Ext.data.HttpProxy({
api: {
read: {
url: 'phps/POSiparisGetir.php?lang=dil(lang)',
method: 'POST'
},
create: 'app.php/users/create',
update: 'phps/POKayit.php?lang=dil(lang)',
destroy: {
url: 'app.php/users/destroy',
method: "DELETE"
}
}
}),
sortInfo: {
field: 'id',
direction: 'ASC'
},
listeners: {
save: function (store, batch, data) {
Ext.Msg.alert(dil('Mesaj'), dil('Kayıt Yapıldı.Teşekkürler.'));
window.bolgesel.siparisler.genel.mnt.dataStoreUpdate = 0;
},
update: function () {
window.bolgesel.siparisler.genel.mnt.dataStoreUpdate = 1;
}
},
groupField: 'grup'
}),
columns: [{
header: dil('Grup '),
width: 20,
sortable: true,
dataIndex: 'grup'
}, {
header: dil('Item No'),
width: 20,
sortable: true,
dataIndex: 'item_no'
}, {
header: dil('Kod'),
width: 40,
sortable: true,
dataIndex: 'code'
}, {
header: dil('Açıklama'),
sortable: true,
dataIndex: 'aciklama'
}, {
header: dil('Fiyat'),
id: "fiyat_column",
width: 30,
sortable: true,
renderer: Ext.util.Format.numberRenderer('$0.000,00/i'),
dataIndex: 'fiyat'
}, {
id: "tipikeadet",
header: dil('Adet'),
width: 30,
sortable: true,
dataIndex: 'adet',
editor: new Ext.form.NumberField({
enableKeyEvents: true,
allowBlank: false,
allowNegative: false,
style: 'text-align:left'
})
}, {
header: dil('Toplam'),
width: 30,
sortable: true,
renderer: function (v, params, record) {
return Ext.util.Format.number(record.data.fiyat * record.data.adet, '$0.000,00/i');
},
dataIndex: 'toplam',
summaryType: 'totalCost',
summaryRenderer: Ext.util.Format.numberRenderer('$0.000,00/i')
}],
view: new Ext.grid.GroupingView({
forceFit: true,
showGroupName: false,
enableNoGroups: false,
enableGroupingMenu: false,
hideGroupedColumn: true,
startCollapsed: true
}),
plugins: summary,
frame: true,
width: 800,
height: 250,
clicksToEdit: 1,
collapsible: false,
animCollapse: false,
trackMouseOver: false,
enableColumnMove: false,
iconCls: 'siparis'
});
I want to change the fiyat column speficitation in the po_combolu_toolbar2 select function.

ExtJS Grid will not sort

I have a grid in ExtJS 3.4 but it will not sort. I am getting this error in firebug when clicking on a column header:
invalid Array.prototype.sort argument
Line 48523
How do I fix it?
Here is the store, column, and grid definition:
function AircraftFeesStore() {
return new Ext.data.JsonStore(Ext.apply({
url: AVRMS.ROOT_CONTEXT + "/ssl/json/general/GetAircraftFees.aspx",
idProperty: 'AircraftOid',
baseParams: {
OwnerOid: 0,
SelectedAircraft: ''
},
fields: ['AircraftOid','NNumber', 'Make', 'Model', 'RegistrationFeeFormatted']
}));
}
var colModel = new Ext.grid.ColumnModel([
{ id: 'AircraftOid', width: 100, sortable: true, locked: true, hidden: true, dataIndex: 'AircraftOid' },
{ header: "N-Number", width: 100, sortable: true, hidden: true, dataIndex: 'NNumber' },
{ header: "Make", width: 250, sortable: true, hideable: false, dataIndex: 'Make' },
{ header: "Model", width: 250, sortable: true, hideable: false, dataIndex: 'Model' },
{ header: "Registration Fee", width: 150, sortable: true, hideable: false, dataIndex: 'RegistrationFeeFormatted' }
]);
var registrationGrid = new Ext.grid.GridPanel(
{
store: aircraftFeesStore,
cm: colModel,
sm: new Ext.grid.RowSelectionModel({ singleSelect: true }),
viewConfig: {
forceFit: true
},
width: 970,
height: 150,
split: true,
region: 'north',
frame: true,
title: 'Selected Aircraft with Total'
});
Try giving
remoteSort:true
in your grid

Resources