I ma newbie to lightning component and I am using the lightning tree grid view in that I like to add some button on one column in child rows. I searched for that option but I couldn't find it.
Please help me out how we can achieve this.
Lightning Component
<div class="slds-m-around_xx-large">
<lightning:treeGrid aura:id="accTree"
columns="{!v.gridColumns}"
data="{!v.gridData}"
keyField="name"
expandedRows="{!v.gridExpandedRows}"/>
</div>
Lightning Controller
var columns = [
{
type: 'text',
fieldName: 'Order',
label: 'Order'
},
{
type: 'currency',
fieldName: 'Total',
label: 'Total'
},
**{
type: 'Button',
fieldName: 'EstimatedDeliveryDate',
label: 'Estimated Delivery Date'
},**
]
I tried adding the button as type "button: but it doesn't work.
Only first column can't be made as button . Otherwise we have an type called button and we can pass the typeattributes to align the button other than the first column
type: 'button',
fieldName: 'Sample',
label: 'Test',
typeAttributes: {
iconName: '',
name: 'sample',
title: 'testtet',
label:'testtet',
alternativeText:'Example',
variant: 'brand',
disabled: false
}
Related
i am trying to print contents of a table on frontend using DataTable in reactjs. So i am facing this weird problem, like i get all data but it prints empty rows(although count of entries remains same with DB). i was first doubtful if the content itself is coming on front so i added a checker and when it is ticked it displays my data for that element. So, my data also comes intact when i press that tick box just that it is not printing on frontend. Any solution?
Some pictures:
Whole Table to print using DataTable on frontend.[![first][1]][1]
[1]: https://i.stack.imgur.com/rA2R9.jpg
2)Data of 4th element of that DB that i want to print is coming when i select it but it is not displaying on front:
3)DB i used to fetch entries:
Note: i have used custom array and other DB, it just works fine with it.
any help or idea about what is going wrong and why it isn't printed on front grid?Some Demo Code i am using to print.
const columns = [
{name: 'CustomerId', selector: row => row.CustomerId, sortable: true},
{name: 'FirstName', selector: row => row.FirstName, sortable: true},
{name: 'LastName', selector: row => row.LastName, sortable: true},
{name: 'Phone', selector: row => row.Phone, sortable: true},
{name: 'Email', selector: row => row.Email, sortable: true},
{name: 'DateOfBirth', selector: row => row.DateOfBirth, sortable: true},
{name: 'Password', selector: row => row.Password, sortable: true},
{
name: '',
button: true,
cell: (row) => <Button variant="link" className="btn-sm" onClick={() => handleRowEdit(row)}>Edit</Button>,
},
{
name: '',
button: true,
cell: (row) => <Button variant="link" className="btn-sm" onClick={() => handleRowDeleteClick(row)}>Delete</Button>,
},
];
<div className="table-responsive">
<DataTable
selectableRows={true}
onSelectedRowsChange={handleRowSelection}
paginationPerPage={Constant.defaultPageNumber}
paginationRowsPerPageOptions={Constant.paginationRowsPerPageOptions}
columns={columns} data={rData.list}
onChangeRowsPerPage={handlePerRowsChange}
paginationTotalRows={rData.totalCount}
className="table table-bordered"
pagination
paginationServer
onChangePage={handlePageChange}></DataTable>
</div>
rData.list is list containing Data Array. and its snapshot is below:
If any other Code is needed i will attach it.
I'm using Antd table and I'm using scroll: {y:...} to have the table contents scrollable. I'd like to have the table auto-size to fit the parent and be responsive to re-sizes. ('auto' sizes the control to fit all its contents, which is not what I need.) Currently I'm just hacking a constant height that works when the app is maximized on my primary monitor. I've tried several CSS overrides, but I can't seem to get this to work as desired.
import { Table } from 'antd';
const columns = [
{
title: 'Name (all screens)',
dataIndex: 'name',
key: 'name',
render: text => <a>{text}</a>,
},
{
title: 'Age (medium screen or bigger)',
dataIndex: 'age',
key: 'age',
responsive: ['md'],
},
{
title: 'Address (large screen or bigger)',
dataIndex: 'address',
key: 'address',
responsive: ['lg'],
},
];
const data = [
{
key: '1',
name: 'John Brown',
age: 32,
address: 'New York No. 1 Lake Park',
},
];
ReactDOM.render(<Table columns={columns} dataSource={data} />, mountNode);
You can take inspiration from the above example
I need to create a contextmenu in ExtJS 7.4 on right click but there's only childtap which only triggers on left-click event.
Is there a way to trigger that event or another for right-click?
I added two solutions. The first is a component solution (here Grid) and the second a global one.
COMPONENT
The solution would be the childcontextmenu listener.
Have a look at the following example (Modern toolkit 6+7)
const menu = new Ext.menu.Menu({
items: [{
text: 'Menu Item 1'
}, {
text: 'Menu Item 2'
}]
});
Ext.define('MyApp.MyGrid', {
extend: 'Ext.grid.Grid',
store: Ext.create('Ext.data.Store', {
fields: ['name', 'email', 'phone'],
data: [{
name: 'Lisa',
email: 'lisa#simpsons.com',
phone: '555-111-1224'
}]
}),
columns: [{
text: 'Name',
dataIndex: 'name',
width: 200
}],
listeners: {
childcontextmenu: function (grid, eObj) {
grid.deselectAll();
grid.setSelection(eObj.record);
menu.showAt(eObj.event.getX(), eObj.event.getY());
eObj.event.stopEvent()
}
}
})
GLOBAL
I can show you how to fire global events, but the problem is the target. In the following example I am using document but you can also use any view.el.on and the target will be always the view. More answers might be found here
Ext.getDoc().on(
'contextmenu',
function(e){
Ext.GlobalEvents.fireEvent('contextmenu', e);
},
Ext.GlobalEvents
);
Ext.GlobalEvents.on('contextmenu', function(eObj) {
console.log('Who dares to RightClick me?');
});
Here's the screenshot of my ui-grid.
Here's the code that creates that filter.
{ field: 'channel_type', displayName: "Type", filter: {
type: uiGridConstants.filter.SELECT,
selectOptions: [
{ value: 'HD', label: 'HD' },
{ value: 'SD', label: 'SD' }
]
}},
{ field: 'price', displayName: "Price", enableFiltering: false, enableSorting: false},
My data is loaded in uigrid from rest api call.
I really can't figure it out from where is it adding that blank option. I haven't found any solution to this issue. Please help me in solving this problem.
Its a known issue, see ui-grid issues
The solution (workaround) is to add some custom style:
#grid1 div div select option:first-child[value=""] {
display: none;
}
Demo Plunker
You have to use filterHeaderTemplate and create your dropdown in it. Here is the example:
field: 'yourField',
filterHeaderTemplate: '<div class="ui-grid-filter-container" ng-repeat="colFilter in col.filters"><select class="grid-filter-control" ng-model="colFilter.term" ng-options="option.value as option.label for option in colFilter.selectOptions"></select></div>',
filter: {
disableCancelFilterButton: true,
term: '',
type: uiGridConstants.filter.SELECT,
selectOptions: [{ value: '', label: 'All' },
{ value: '1', label: 'Something' },
{ value: '2', label: 'Something Else' }]
}
Defining term will select your first option and the empty one is not going to show.
I am using Angular 1.5 and am using the UI Grid. I was wondering is there a way to put a drop-down (i.e. a select) in a header column ? I know you can do it within the "data" cells/rows of the table but unsure if it can be done in the header title ?
See the below image link to see a visual of what I mean. I want to put the dropdown into the column header called "Value"
enter image description here
Thanks - Ronan.
You can specify a filter with selectOptions for displaying a dropdown in the header.
Example:
columnDefs: [{
name: 'id', field: 'id'
},
{
name: 'value', field: 'value',
filter: {
type: uiGridConstants.filter.SELECT,
selectOptions: [{ value: '1', label: 'One' },
{ value: '2', label: 'Two' }]
}
}]
For more details check filter section in this link UI Grid ColumnDef - Filters