We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
tmpl
let editButton = '<a class="btn btn-primary" href="#" onclick="editTrainingSession({id})">Edit</a>' let cancelButton = '<button class="btn btn-secondary" onclick="cancelTrainingSession({id})">Cancel</button>' let deleteButton = '<button class="btn btn-danger" onclick="deleteTrainingSession({id})">Delete</button>'
{ title:'Actions', tmpl: object.is_cancelled ? editButton: actionButtons}
Cancel
is_cancelled
true
editButton
actionButtons
let editButton = '<a class="btn btn-primary" href="#" onclick="editTrainingSession({id})">Edit</a>' let cancelButton = '<button class="btn btn-secondary" onclick="cancelTrainingSession({id})">Cancel</button>' let deleteButton = '<button class="btn btn-danger" onclick="deleteTrainingSession({id})">Delete</button>' let actionButtons = `${editButton} ${cancelButton} ${deleteButton}` var teamTrainingsGrid = $('#teamTrainingsGrid').grid({ primaryKey: 'id', uiLibrary: 'bootstrap4', dataSource: 'training_sessions/', columns: [ { title: 'Date', field: 'date' , sortable:false}, { title: 'Time', field: 'time' , sortable:true }, {title:"Duration", field:"duration", sortable:true}, { title: 'Name', field: 'name' , sortable:true }, { title: 'Venue', field: 'venue', renderer:(value) =>value.name, sortable: true }, { title: 'Status', field: 'status' , sortable: true }, { title: 'Notes', field: 'notes', sortable: true }, { title:'Actions', tmpl:actionButtons} ], pager: { limit: 20, sizes: [10, 20, 50, 100] } })
{ "total": 5, "records": [ { "id": 133, "is_cancelled": true, "name": "Training Camp", "description": "Training Camp", "venue": { "id": 16, "name": "Christopher Camp" }, "time": "03:10 PM - 04:10 PM", "date": "June 01, 2022", "duration": "1 hour", "status": "Cancelled", "notes": "" }, { "id": 134, "is_cancelled": false, "name": "Training Camp", "description": "Training Camp", "venue": { "id": 16, "name": "Christopher Camp" }, "time": "03:10 PM - 04:10 PM", "date": "June 03, 2022", "duration": "1 hour", "status": "Scheduled", "notes": "" }, ] }
Google Chrome - Version 102.0.5005.61 (Official Build) (arm64)
Mac M1 Monterey
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Question:
How to conditionally render a different
tmpl
based on a property on a row on the data source, i.e. a property of the object?With code:
How can I do this:
{ title:'Actions', tmpl: object.is_cancelled ? editButton: actionButtons}
That is, I want to hide the
Cancel
button if the session is already cancelled with theis_cancelled
property beingtrue
If the objet is cancelled,
tmpl
should be justeditButton
only, if not cancelled then allactionButtons
UI
Code
Grid:
Returned data from endpoint:
Sofware versions:
Browser:
Google Chrome - Version 102.0.5005.61 (Official Build) (arm64)
Environment
Mac M1 Monterey
Any help is much appreciated,
Thanks!
The text was updated successfully, but these errors were encountered: