Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Header Row not binding #6

Closed
tpever opened this Issue · 8 comments

3 participants

@tpever

Hi,

thanks for this great knockout plugin. Working great with datatable.

Recently I found one problem, if i bind element thead or tfoot ko binding doesn't seems working.
Please have a look at
http://jsfiddle.net/fPaQs/46/

I have added one parameter TableFor and added with Cell1 Title doesn't seems working.

Can you please help me to find work around for same ? I want to show multiple totals in footer and some count on header.

Thanks.

@ducka
Owner

Heya tpever,

Thanks for opening this issue. It seems I hadn't considered this usage scenario when I wrote this binding.

The reason why knockout does not automatically bind the <span data-bind="text: TableFor" /> element in the header is because I've explicitly told Knockout JS not to. You'll notice towards the bottom of knockout.bindings.dataTales.js I'm returning an object in the "init" function of the handler.

return { controlsDescendantBindings: true };

This object instructs Knockout JS that the dataTables binding will take complete control over binding process of every element within the <table></table> tags. This so far has proven to be a necessary step in writing this binding.

Currently, the dataTables binding only binds elements within each row of the table, and does not bind elements outside of that like <thead> or <tbody>. This is the reason why the <span data-bind="text: TableFor" /> tag isn't binding how you would expect it.

For the moment, I can't really suggest a simple workaround for this issue, but I will try to write a fix for this soonish. In the mean time, if you figure out a nice way of solving this problem yourself, feel free to open a pull request, and I'll see what I can do about merging your changes into the codebase.

Thanks for logging this issue!

Lucas

@tpever

Thanks Lucas for reply,

Currency I couldn't find any easy work around for same, if we remove controlsDescendantBindings: true then creates duplicate binding and other issues which i couldn't figure out.

Right now I have added one more computed function and subscribed on fields changes expected. and in compute method explicitly writing values directly to elements.

Let me know if you find any solution to this will really helpful.

Thanks and regards

@AndersMalmgren

I also need this, want to add a checkbox in one of the columns for a check-all feature

@ducka ducka closed this issue from a commit
@ducka ducka Fix #6: The dataTables binding will now bind elements that exist outs…
…ide of the rows of the table body (like in the header or footer of the table).
61238c5
@ducka ducka closed this in 61238c5
@ducka
Owner

OK, this issue should be sorted out now. Let me know if this doesn't solve your problem.

@AndersMalmgren

http://jsfiddle.net/FzXT7/

Works very well, thanks, I'm going to use your binding for an advanced business case, so it will be very well tested :P

@ducka
Owner

Good to hear :) I've also used your check-all feature in the demo that is included in this repo. It's basic, but it might serve as inspiration.

@AndersMalmgren

No problem, here is a more complete one

http://jsfiddle.net/jEwmk/

@ducka
Owner

Nice. Looking good :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.