I feel sure this is a simple answer but as a rookie I'm failing to see it. I just want a table to have column 0 and 2 disabled from the sort, then the default sort to be column 1. Two separate commands, but while they work individually they seem to clash together.
I can have my columns 0 and 2 disabled and the table works perfectly. Or I can have my initial sort set to column 2 and the table works perfectly. But when put together my remaining sortable columns will only allow one click, they cannot be toggled acending, descending.
Can anyone help, as I just can't figure out what I'm doing wrong? Thank you in advance!
Try this demo:
$('table').tablesorter({
sortList : [[ 1, 0 ]],
headers : {
0 : { sorter: false },
2 : { sorter: false }
}
});
Related
I have List of objects which I am iterating using ng-repeat.
List = [{
type = "CC",
cardNum : 125,
accNum : null,
amount =125,
isCard : true
},
{
type = "LN",
cardNum : null,
accNum : 125,
amount =125,
isCard = false
},
....
]
Now, based on selection from Radio of isCard (two radio, is Card and is Non Card), I need to show two respective field such as cardNum or accNum.
Now the problem is, when iterate and add both combination of isCard and isNonCard account and remove element in between, all the elements after that are set to pristine where it was dirty before.
scenario 1:
selected 1st as Card Acc - index 1
2nd as Non Card - index 2
3rd as card acc -index 3
touched the fields such that there is error for all 3 entries above
now, remove 2nd entry by using splice.
Issue: Now the 3rd element index is updated to 1(which is correct) but field is reset to pristine and error is hidden. How can I stop this so that error will still appear for 3rd element at updated index.
I managed to fix this issue. Even after using track by index, it did not work so I had to add trackIdentifier in object. Now when I tracked based on it, it started working and error messages appeared correctly.
I am trying to add rows to a grid using dhtmlx in java, following is the code.
var combinedColumn = "displayText";
displayOptionsGrid.addRow(selectedID, [ displayOptionsGrid.getRowsNum() == 0 ? 1 : 0, combinedColumn]);
What the function is supposed to do is that if the number of rows is zero it adds the first row as checked and then the rest as unchecked. The error which I am facing is, I delete the rows one by one and try to re-add the rows in the same session with some other row at first than the row I added previously, but can't. I can only add the row which I added first previously as the first row.
When I use grid.clearAll() it works fine. Can someone tell me the exact thing we do in clearAll() which we don't in deleteSelectedRows() in dhtmlxgrid. Thanks.
Please, check your selectedID attribute.
Note that each row should have a unique id, so adding a row with the id existing in your grid will break the grid.
I have a table with 3 columns and when I sort column 1 or 2 then I would like to sort column 3 by descending.
I'm using fnPreDrawCallback (I tried to use fnDrawCallback too).
Here is my code:
"fnPreDrawCallback": function (oSettings) {
var column = oSettings.aaSorting[0][0];
if (column !== 3) {
oSettings.aaSorting.push([3, "desc"]);
}
}
This code looks fine, but, for example, when I sort column 1, the column 3 isn't sorted and, more awkward, when I try to sort at a 2nd time on column 1, the sort result is always ascending.
How can I achieve this?
The data has already been "sorted" by the time the preDrawCallback is fired, so changing aaSorting in here won't change the outcome of the table.
You can verify by checking oSettings. There is aiDisplay and aiDisplayMaster properties. aiDisplay is an ordered array of the elements that changes as they are sorted from clicks on a th. aiDisplayMaster is the original order that the data came back from the server or was existing on the page.
I would recommend manually calling fnSort from the click event of your th elements. To do this you will have to unbind the click event that datatables installs.
Create a function like this and call it from fnInitComplete so it only runs after datatables has been setup.
function unbindDTSorting() {
//unbind sort event, prevent sorting when header is clicked
$j('[id$=table] th').unbind('click.DT');
//create your own click handler for the header
$j('[id$=table] th').click(function(e) {
var oTable = $j('[id$=table]').dataTable();
//here is where you can do all of your if/else logic to create the desired multidimensional sorting
if(this.cellIndex == 3){
oTable.fnSort( [ [2, 'asc'],[3,'desc' ]] );
}
});
}
I want to persist the column order via localStorage which is working. However, the column chooser gives the order of the columns based on the current order not the original order.
Example:
3 column table where 0 is first, 1 == second, 2 is last column
0,1,2
choose column order to put last column in first, order becomes
2,0,1
choose column order again and put (original last column) back into last and order becomes:
1,2,0
because it resets the column numbers based on current order rather than ORIGINAL order. How to fix this?
onClickButton: function () {
$(this).jqGrid('columnChooser', {
done : function (perm) {
if (perm) {
localStorage["OD_Table_Col_Order"] = perm;
$(this).jqGrid("remapColumns", perm, true);
}
}
});
}
I think that you can find the solution if you would use remapColumns parameter of jqGrid as additional information.
One more way would be to save in localStorage the array of name properties of colModel items instead of the indexes perm.
I have a DataGrid, created programmatically and loaded from ItemFileReadStore.
I want the first column of DataGrid always be sorted in descending order and disabled for user for sorting. Any other column should be available for sorting as a secondary sortable.
I don't want to give users such a powerful(complex and confusing) feature, as sorting by multiple columns, because there are too many columns in my grid.
So, it should be one sortable column for user and another one "already sorted unsortable" column in fact.
Does anyone know how can this be achieved?
Thanks.
To sort the first column add "sortInfo:-1" when you created your object.
To allow sorting the grid from any other columns but not the first you need to overwrite the function canSort.
To create you grid should now look like this .
dijit.grid.DataGrid({
canSort: function (sortInfo) {
if (Math.abs(sortInfo) == 1){
return false;
} else {
return this.inherited("canSort", arguments);
}
},
sortInfo: -1, .....
If you need to sort on more as one column you need dojox.grid.enhanced.plugins.NestedSorting.
http://dojotoolkit.org/reference-guide/1.7/dojox/grid/EnhancedGrid/plugins/NestedSorting.html