How can we improve Breeze.js?

Retrieve values of an enum server side to be able to use it client side

106 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    ThierryThierry shared this idea  ·   ·  Admin →

    6 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • AnonymousAnonymous commented  · 

        As a workaround in the meantime, you could create global "enums" from your metadata like this:

        manager.fetchMetadata()
        .then(function (data) {

        // extract all enums als global objects
        ko.utils.arrayForEach(data.schema.enumType, function (c) {
        window[c.name] = {};
        ko.utils.arrayForEach(c.member, function (m) {
        window[c.name][m.name] = m.value;
        });
        });

        });

        So if you had an enum called "Status", you would now have a global object that you can call:

        var currentStatus = Status.Done; //returns the value as defined in the server side enum

      • FredrikFredrik commented  · 

        Yeah, pls, at least show us an example of how to bind the enums to a knockout select dropdown

      • MurrayMurray commented  · 

        Yes please expose these. As stated above you are passing these to the client but we can't access them in the breeze api. I would give this 10 votes if i had it

      • Mark van ProctorMark van Proctor commented  · 

        The enumType and all its values / names are in the metadatastore... if only they were accessible :)

      • Laurentiu MacoveiLaurentiu Macovei commented  · 

        This is so trivial, you're actually have it in the metadata.
        Don't understand why they haven't epxosed it in the first place.

      • Adam PawseyAdam Pawsey commented  · 

        From what I can see this is just a matter of exposing the data in the api? looking at the metadata it includes the definitions for the enums. There just isn't a way to actually get that data out of the metadata store. Looking at the relevant property of my type, it's enumType property has the value Edm.Self.EnumType but it's just a string and no where else can you actually just get those values.
        Correct me if I'm wrong?

      Feedback and Knowledge Base