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

Alter TD value and re-sort, doesn't work. #106

Open
marcreig opened this issue Nov 24, 2016 · 3 comments
Open

Alter TD value and re-sort, doesn't work. #106

marcreig opened this issue Nov 24, 2016 · 3 comments

Comments

@marcreig
Copy link

marcreig commented Nov 24, 2016

Hi again. Last changes made my day. Them taken a long time, but already done! So thanks again.

Now about this feature:

  • I've a table, with normal TDs with some content on'em, text and numbers. Content is inside an <span>.
  • I've created a JS snipet which on TD-content click, it changes from span to input-text, and let's you alter the content. On blur then, it saves changes on DB, and comes back from input-text to span. Quite tipical nowadays.

Expecting a behaviour like the one exposed on info text:

When you add table rows or whole table from client side, use $.bootstrapSortable({ applyLast: true }) function to add sortability to parts/tables that were not present at document.ready. Use optional paramater applyLast=true if you want to preserve the last used sorting.

I've called the
$.bootstrapSortable({applyLast: true, sign: 'reversed'});

But nothing happens. Do not re-sorts the changed row.
So to solve this, I've basically added an snippet on my "from input-text to span" part, which changes the "data-value" from the span parent TD. And after that, I call the $.bootstrapSortable({applyLast: true, sign: 'reversed'}); and then it works.

$(this).parents('td').attr("data-value", $(this).val().toUpperCase()); //fill data-value to re-sort on change.

Question is: is this the normal behaviour? Or it is expected to re-map the TD "data-value" automatically when $.bootstrapSortable({applyLast: true, sign: 'reversed'}); is called?

Thanks and kind regards.

@drvic10k
Copy link
Owner

in this case you are not adding new row, you are just changing content of the cell, but the cell has already set the data-value attribute from the previous state

your solution is fine

@bergano65
Copy link

that's exactly my case. you change content of the cell. but cell has already data-value attributes from previous state. this destroys sorting by clicking headers also. if it's by design probably specify this in documentation? that if you change cell value what you should do? or call bootstrapTable() again. or set data value attribute. is I understand not always will work because you use moment.js on datavalue attribute. probably add method "setCell()" that will set attribute hiding details of implementation from user? thanks in advance )

@drvic10k
Copy link
Owner

unfortunately the same attribute is used to predefine the data-value in markup and also to fill the values by plugin
possible solution would be to use separate attributes for predefined values, I will keep this as a possible improvement

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

No branches or pull requests

3 participants