#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0

    Filter > Date field submenu order incorrect (random)


    Date field option values in the Filter submenu were not sorted correctly - they appear in random order.In the drop down submenu dates are not sorted,actually they sorted in alpha but not not depending on the dates when they have occurred.
    Following is the code which I have used:-

    function getGridData(sCol) {
    var nCol = getColumnIndex(sCol), aUniqueValues = [],
    sFieldType = window.aoColumns[nCol].sFieldType.toLowerCase(),
    sSeparator = sFieldType == "checkbox" || sFieldType == "multiselect" ? "|" : sFieldType == "csv" ? "," : "",
    aTrs, aData, sVal, aVals;

    if (window.oDataTable.dataTableSettings[0].bFiltered) {
    aTrs = oDataTable.$('tr', { "filter": "applied" });
    aData = [];
    aTrs.each(function () {
    aData.push(oDataTable.fnGetData(this));
    });
    }
    else {
    aData = window.aaData;
    }

    for (var i = 0; i < aData.length; i++) {
    sVal = aData[i][nCol];
    if (sVal && sVal != " ") {
    yellow Code:
    if (sFieldType == "date")
                    sVal = $.fullCalendar.formatDate(new Date(ticksToDateTime(sVal)), "ddd, MMM d, yyyy");

    if (sSeparator) {
    aVals = sVal.split(sSeparator);
    for (var j = 0; j < aVals.length; j++) {
    if (aUniqueValues.indexOf(aVals[j]) == -1)
    aUniqueValues.push(aVals[j]);
    }
    }
    else if (aUniqueValues.indexOf(sVal.toLowerCase()) == -1) {//Per team design decision, ALL Rapid Hire screen media text is lower case
    aUniqueValues.push(sVal.toLowerCase());
    }
    }
    }

    aUniqueValues.sort(basicSort);

    return aUniqueValues;
    }

    I think I need to change sth which I have highlighted in the yellow.So any one know about this issue?.If yes please reply to this post.

    Thanks in advance..
  2. #2
  3. JavaScript is not spelt java
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2011
    Location
    Landan, England
    Posts
    743
    Rep Power
    165
    I'm guessing you might intend to exclude an empty value, rather than specifically a space?
    Code:
    if (sVal && sVal != "") {
    but this is probably not the issue.

    Use window.alert(sFieldType) or console.log(sFieldType) to discover what value it contains.

    I assume, also, that ticksToDateTime is defined somewhere and works as you expect it to?

    You need to highlight your code and click the hash sign (#) to wrap it in code tags - it is very difficult to read otherwise. Previewing your post before submitting it will help with this.
    Last edited by AndrewSW; December 22nd, 2012 at 09:32 PM.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0

    Date field option values in the Filter submenu were not sorted correctly


    1.What value we can include instead of space for if condition
    if (sVal && sVal != "") {..?

    2.I see date as message in the window when I try to include window.alert(sFieldType) and nothing in the error logs when I try to include console.log(sFieldType) after if condition
    if (sFieldType == "date").


    3.The function ticksToDateTime is shown mentioned below.

    function ticksToDateTime(nTicks) {
    var N_EPOCH_TICKS = 621355968000000000;
    var N_TICKS_PER_MILISECOND = 10000;

    return (nTicks - N_EPOCH_TICKS) / N_TICKS_PER_MILISECOND;
    }

    But I don't understand the code for function ticksToDateTime though because I'm working on already existed project(enhancement). Can anyone please help me with this further.


    Thanks,
    Swetha.

IMN logo majestic logo threadwatch logo seochat tools logo