2

Using jqxGrid to make a table with data (obviously).

I've got my angular directive element loaded in the jqxGrid, data updates the grid fine, but it just stays there, unrendered and I can't figure out how to trigger the rendering.

Here are my jqx settings:

   AppvisAgentsCtrl.settings = {
        autowidth: true,
        ...
        columns: [

            { text: 'A', cellsrenderer: insertActionMenu, width: 50 },
           ...
        ]
    }

Where insertActionMenu is simply this right now:

function insertActionMenu(){

    var output = [
        '<actionmenu></actionmenu>'
        ].join('');

    return output;
}

My problem is that in the DOM inspector, I'll just see <actionmenu></actionmenu> sitting there on the page in every column and I want to tell it to render into the directive it's supposed to be.

Yes, the actionmenu directive works I use it several other times throughout the application.

EDIT

Everything is inside jqx-grid directive:

<jqx-grid 
    jqx-settings="appvisagents.settings" 
    jqx-source="appvisagents.testData.things">
</jqx-grid>
4

2 回答 2

1

好的,所以我发现这个工作的唯一方法是在设置中使用“渲染”事件并一个一个地编译我的操作菜单。

不幸的是,在注入它之前我无法 $compile 它,因为 jqx-gid 只会注入文本和 HTML,并且任何附加对象的尝试都会导致[Object object]被附加。

AppvisAgentsCtrl.settings = {
        autowidth: true,
        ...
        columns: [

            { text: 'A', cellsrenderer: insertActionMenu, width: 50 },
           ...
        ],
        rendered: function(){ 
            $element.find('actionmenu').each(function(i,e){
                $compile(e)($scope);
            });
        }
    }

对我来说,这不是一个好的解决方案,原因如下:

  • 尽管为此任务强加了 jqwidgets,但我想尽可能避免使用 jQuery
  • 我不知道这将如何影响数千行的性能
  • 我仍然需要修补将此指令绑定到与行对应的数据模型

但是我确实让它渲染了。

于 2014-11-10T16:01:34.463 回答
1

假设这是在指令中发生的,您需要'<actionmenu></actionmenu>'在添加它之前进行编译。看这里的$compile服务

于 2014-11-09T21:41:40.843 回答