File size: 2,242 Bytes
2252f98 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
var dagcomponentfuncs = window.dashAgGridComponentFunctions = window.dashAgGridComponentFunctions || {};
// Store original data globally
window.gridOriginalData = null;
dagcomponentfuncs.ModelLink = function(props) {
if (!props.data.Model_Link) {
return props.value; // Just return text if no link
}
return React.createElement(
'a',
{
href: props.data.Model_Link,
target: '_blank',
style: {
color: '#007bff',
textDecoration: 'none'
}
},
props.value
);
};
dagcomponentfuncs.PinRenderer = function(props) {
// Store original data when component first renders
if (!window.gridOriginalData) {
const allRows = [];
props.api.forEachNode(node => {
allRows.push({...node.data});
});
window.gridOriginalData = allRows;
}
return React.createElement(
'div',
{
onClick: function() {
const api = props.api;
const newValue = !props.value;
// Create a copy of the original data and update pin state for clicked row only
const allRows = window.gridOriginalData.map(row => ({
...row,
// Preserve existing pin states and only update the clicked row
pinned: row.Model_Display === props.data.Model_Display ? newValue :
(row.pinned || false)
}));
// Update window.gridOriginalData to maintain pin states
window.gridOriginalData = allRows;
// Separate rows
const pinnedRows = allRows.filter(row => row.pinned);
const unpinnedRows = allRows.filter(row => !row.pinned);
// Update both sections
api.setPinnedTopRowData(pinnedRows);
api.setRowData(unpinnedRows);
},
style: {
cursor: 'pointer',
textAlign: 'center',
fontSize: '16px'
}
},
props.value ? '📌' : '☐'
);
}; |