SplitAt()后,DhtmlXGrid的LinkBut​​tons无法正常工作

时间:2017-01-05 11:56:07

标签: dhtmlx

我有一个DhtmlXGrid,它有链接按钮和排序功能。它工作得很好,但是,我最近添加了splitAt()以支持固定列,在单击网格标题进行排序后,没有调用此链接按钮onClick。下面是我的代码,

function initGrid() {
setGridSize();
gridMenu.setIconsPath('..');
gridMenu.setImagePath('..);
gridMenu.renderAsContextMenu();
gridMenu.attachEvent('onClick', onButtonClick);
gridMenu.loadXML('..');
grid.setIconsPath('@urlDhtmlxImages');
grid.setImagesPath('@urlDhtmlxImages');
grid.enableContextMenu(gridMenu);
grid.attachEvent("onBeforeContextMenu", onShowMenu);
grid.setSkin('dhx_black');
grid.enableColumnAutoSize(false); // Double-click header will size to fit
// grid.attachEvent("onBeforeSorting", onBeforeSort);
grid.attachEvent("onEditCell", onEditCell); // Edit Cell
//grid.attachEvent("onCellMarked", onCellChanged);
var combobox1 = grid.getCombo(4);
combobox1.put("Yes", "Yes");
combobox1.put("No", "No");

var combobox2 = grid.getCombo(5);
combobox2.put("Yes", "Yes");
combobox2.put("No", "No");
//grid.enableSmartRendering(true);
//grid.attachEvent("onDhxCalendarCreated", createCalender);
grid.init();
grid.splitAt(1);
grid.load('...', FillGirdDataOnPageLoad, 'xml');

}


this is how I'm calling Link actions,
// Set up action links
$("a.action-link[data-link-init='0']").each(function (e) {
$(this).attr('data-link-init', '1');
$(this).click(function (e) {
onActionLinkClick($(this).prop('id'));
if (e) { e.preventDefault ? e.preventDefault() : e.returnValue = false; };
});
});

2 个答案:

答案 0 :(得分:1)

grid.attachEvent("onAfterSorting", function (index, type, direction) {
$("a.action-link[data-link-init='1']").each(function (e) {
$(this).click(function (e) {
onActionLinkClick($(this).prop('id'));
if (e) { e.preventDefault ? e.preventDefault() : e.returnValue = false; };
});
});
});

答案 1 :(得分:0)

我需要在排序后再次设置actionLinks,

grid.attachEvent("onAfterSorting", function (index, type, direction) {
$("a.action-link[data-link-init='1']").each(function (e) {
$(this).click(function (e) {
onActionLinkClick($(this).prop('id'));
if (e) { e.preventDefault ? e.preventDefault() : e.returnValue = false; };
});
});
});

这对我现在很有用。