-
Notifications
You must be signed in to change notification settings - Fork 284
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
Feature request: Support more than column_number, like columnDefs.targets #513
Comments
Please provide a minimal code sample to explain what do you exactly mean / which to work that way... |
Desired Feature:<table>
<tr>
<th class="Description">Description</th>
<th class="Name">Name</th>
</tr>
</table> var myTable = $('#example').DataTable();
yadcf.init(myTable, [
{ targets : '.Name' }
]);
}); Notice how to init a Imagine now, that I can re-use the I do have a temporary work around. /**
* Takes a list of YADCF definitions and filters them down if it can locate a column on the table with that target
* The target should usually be a class without the "."
* @param { DataTable } dataTableApi The target data table to trigger the edit against.
* @param { Array } YADCFDefinitions The array of YADCF definitions.
* @returns { Array } The array of YADCF definitions for matching column targets.
*/
function FilterYADCFDefinitionsByColumnDefsTarget(dataTableApi, YADCFDefinitions) {
return YADCFDefinitions.filter(function (YADCFDefinition) {
var column = dataTableApi.column(YADCFDefinition.targets);
// targets lets you pass a class name as a string (without the ".")
// column-selector strings are essentially jQuery selectors. So we add the "." back.
if (jQuery.type(YADCFDefinition.targets) === "string" &&
YADCFDefinition.targets !== "_all" &&
YADCFDefinition.targets.indexOf(".") === -1) {
column = dataTableApi.column("." + YADCFDefinition.targets);
}
if (column.index() >= 0) {
YADCFDefinition.column_number = column.index();
return YADCFDefinition;
}
});
} To use this, you have to add an additional param to your yadcf definitions called |
Please post a minimal working example (jsfiddle / etc) |
http://jsfiddle.net/Lord_Zero/7zx8htof/40/ Both tables share the same |
… selectors (instead of hard coded column_number) #513 https://datatables.net/reference/type/column-selector
Try 0.9.4.beta.10, see it in action here Usage is as follows (notice its not camel case since from the start I used
|
@vedmack Great job on this! I appreciate it. I am also thankful that you pass the When do you expect to do a release? |
@VictorioBerra, you are welcome... if you referring the npm module update - then I will update the beta on npm the day after tomorrow p.s Thanks for your code that I based this feature on |
Checking in, any word on the NPM package? |
…ility in column selectors (instead of hard coded column_number) #513
Heya... |
Just like
columnDefs.targets
it would be nice to support a class name.I have a set of default
<th>
columns across a few of my tables, some define them in different orders. Because of this, I use thestring
target type so my defs are matched up to the column name and everything just works.Being forced to provide a 0-based index to
column_number
throws a wrench in my setup. I now have to iterate the<th>
columns and store my YADCF definitions in such a way that they can be retrieved by a name, and then I must assign numbers. This is some pretty unfortunate boilerplate.Please support a
target
options that can take a string.The text was updated successfully, but these errors were encountered: