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

Wrong sorting in combo box from alt-editor form #191

Open
stanchooo opened this issue Sep 17, 2021 · 0 comments
Open

Wrong sorting in combo box from alt-editor form #191

stanchooo opened this issue Sep 17, 2021 · 0 comments

Comments

@stanchooo
Copy link

Dear all,

I have the following code - A DataTable including one column (type=select) which can be edited using altEditor edit form.

<script>
	$(document).ready(function() {
		$('#my_table').DataTable( {
			data: [{col1: "b"}],
			destroy: true,
			columns: [
			{
				data: "col1",
				title: "Column 1",
				required: true,
				type: "select",
				options: { "b" : "A Text (b)", "a" : "B Text (a)", "2" : "C Text (2)", "1" : "D Text (1)"}
            }
			],	
			dom: 'Bfrtip',        // Needs button container
			select: 'single',
			altEditor: true,     // Enable altEditor

			buttons: [
				{ text: 'Add', name: 'add' },
				{ extend: 'selected', text: 'Edit', name: 'edit' },
				{ extend: 'selected', text: 'Delete', name: 'delete' }
			]
		});
	});
</script>

<table id="my_table"></table>

When I press Edit and open alt-editor then col1 can be changed selecting from the following possible options:
options: { "b" : "A Text (b)", "a" : "B Text (a)", "2" : "C Text (2)", "1" : "D Text (1)"}

Unfortunately the order (sort) of the elements in the combo box in altEditor-edit-form is not good.
The elements are ordered as follows:

<select class="form-control" id="col1" name="Column 1" placeholder="Column 1" data-special="" data-errormsg="" data-uniquemsg="" data-unique="false" required="">
	<option value="1">D Text (1)</option>
	<option value="2">C Text (2)</option>
	<option value="b">A Text (b)</option>
	<option value="a">B Text (a)</option>
</select>

The system sorts them out as follows:

  1. Sorts by value and puts first (ONLY integer values).
  2. The rest of the elements (string keys) are not sorted The are just placed as they are ordered in the options {} definition of the column above:

I would like to:

  1. Disable sorting the elements with integer value and have the elements as ordered in options {} definition
    OR
  2. Sorts the elements in the select box alphabetically by name (A Text (b), B Text (a), C Text (2), D Text (1))

The required sorting is in the combo box from the altEditor-edit-form is:

	<option value="b">A Text (b)</option>
	<option value="a">B Text (a)</option>
	<option value="2">C Text (2)</option>
	<option value="1">D Text (1)</option>

Thanks a lot,
Stan

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

No branches or pull requests

1 participant