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>

2 Answers 2

1

Assuming this is happening inside a directive, you'll need to compile '<actionmenu></actionmenu>' before adding it. see $compile service here

Sign up to request clarification or add additional context in comments.

2 Comments

You mean in the compile function of the directive or in insertActionMenu()?
the $compile service can only be used inside a directive, and you need to compile adding the actionMenu directive inside the function, so that angular knows it needs to replace that with the real directive dom. I realise that code is probably not in a jqxgrid directive in your case so I´m not sure if you can do it. Maybe trying this: stackoverflow.com/questions/22370390/…
1

Ok so the only way I found this to work is to use the 'rendered' event in settings and $compile my actionmenus one by one.

Unfortunately, I could not $compile it before injecting it as jqx-gid will only inject text and HTML and any attempt to append an object results in [Object object] being appended.

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

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

For me this is not a good solution for the following reasons:

  • Despite having the jqwidgets imposed for this task, I wanted to avoid using jQuery as much as possible
  • I don't know how this will affect performance over thousands of rows
  • I still need to tinker to bind this directive to the data model corresponding to the row

However I did get it to render.

1 Comment

Did you find a better solution yet?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.