Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to custom header #2079

Open
SEONG-GI-IN opened this issue Nov 5, 2024 · 0 comments
Open

How to custom header #2079

SEONG-GI-IN opened this issue Nov 5, 2024 · 0 comments
Labels

Comments

@SEONG-GI-IN
Copy link

I want to insert a plus button image into the tui grid header. What should I do?

let grid = {};

grid.readData = () => {
let params = {
startDt: $('#startDt').val(),
endDt: $('#endDt').val(),
empName: $('#empName').val(),
empSeq: $('#loginVo [name=empSeq]').val(),
auth: $('#auth').val(),
};
CommonUtil.postAjax('/comm/getComDivCdList', params).done(function(result) {
grid.resetData(result.data);
});
}

grid.gridInit = () => {
const Grid = tui.Grid;
Grid.applyTheme('clean');
const gridInstance = new Grid({
el: document.getElementById('grid'),
columns: [
{
header: ' ',
name: 'plusBtn',
width: 30,
align: 'center',
headerRenderer: {
type: CustomHeaderRenderer,
},
},
{
header: '시스템코드',
name: 'expend_date',
width: 90,
},
{
header: '공통코드',
name: 'mgt_name',
minWidth: 90,
},
{
header: '공통코드명',
name: 'res_note',
minWidth: 80,
},
{
header: '설명',
name: 'cause_date',
width: 120,
},
{
header: '순서',
name: 'doc_no',
width: 80,
},
],
columnOptions: {
resizable: true,
},
header: { height: 30, align: 'left' },
bodyHeight: 550,
rowHeight: 'auto',
});

return gridInstance;

};

// Custom Header Renderer Class
class CustomHeaderRenderer {
constructor(props) {
const button = document.createElement('button');
button.innerHTML = '추가';
button.style.border = 'none';
button.style.background = 'none';
button.onclick = () => {
alert('헤더 버튼 클릭됨!');
};
this.el = button;
}

getElement() {
	return this.el;
}

}

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant