2

I have following problem. In my server side code I have an enumeration that defines the Type of Task I have. In my front en webpage I show all my tasks in a table that contains the column "Task Type". This column actually shows the enumeration value translated with lingua JavaScript library.

So in my JavaScript Library I have something like this for English

enumTaskType_0  => "Unknown"
enumTaskType_1  => "Problem"
enumTaskType_2  => "Incident"
enumTaskType_3  => "Change Request"

and for German

enumTaskType_0  => "Unbekannt"
enumTaskType_1  => "Problem"
enumTaskType_2  => "Ticket"
enumTaskType_3  => "Änderungsantrag"

my c# enumeration obviously is then

public enum SupportTaskType
{
    Unknown = 0,
    Problem= 1,
    Incident= 2,
    Change Request= 3
}

Now my Problem: All columns in my table should be Sortable. It sorts alright.. but the sorting is done with the Value of the enumeration, so in all languages it's sorted differently..

I mean it is technically sorted, but for the user its is more like "grouped" and not alphabetically sorted.

Any suggestions?

I was thinking that I could send a JSON from my JavaScript to my Server and implement something like in this Question...

But there must be a better way!

Any help would be appreciated.

Community
  • 1
  • 1
CodeHacker
  • 2,127
  • 1
  • 22
  • 35

1 Answers1

1

Rather than producing the html with server code, I assume that that's the way you're doing it, I would create and array (with the number concatenated) and after your translator executes I would user Array.sort() and then split each value.

var taskType = ["Unknown|1", "Problem|2", "Incident|3", "Change Request|4"];
taskType.sort();
Ted
  • 3,985
  • 1
  • 20
  • 33
  • Oh no I'm not producing any HTML from the server. I'm getting a JSON object with an array of objects in the Javascript and then I'm binding that array with knockout.js – CodeHacker Aug 27 '14 at 17:30
  • Problem is I can't sort it on the client. I need t go get the data sorted from the server. I have a paging on my view – CodeHacker Aug 27 '14 at 17:34
  • You've answered your own question then. I don't see the point of this exercise... – Ted Aug 28 '14 at 05:51