Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Session Variables

    Hi,

    Up until now, if I wanted to reference a selected row in a ListGrid, I'd use the following:

    record = myListGrid.getSelectedRecord();
    detailSearchForm.findDetail(record.id);

    However, if the ListGrid gets refreshed, then my selected record is lost.

    What's the best way to persist the selected id ?

    Should I just use a global JS variable of some kind?

    Or does ISC have some sort of session object that I should use to store variables?

    Thanks,
    Mike

    #2
    In terms of finding the record, it depends on your application, but List APIs such as list.find() are available on the ResultSet accessible as listGrid.data.

    As far as storing state - just think of it in an ordinary object oriented way: is the state you want to store specific to a component, request or other object? If so store it there, if it's truly global, store it globally.

    Comment


      #3
      I know how to use

      var somevar;

      within a function.

      But where do I put a general var that would be accessible to the whole ListGrid or Window or app?

      For the whole app, I'd just put it in some stand-alone JS.

      But I'm a little unclear on how to embed it in the ISC environment.

      Mike

      Comment


        #4
        It's the same with SmartClient. SmartClient is JavaScript, it doesn't change the language.

        So, window.someVar = someValue; would store a global variable.

        It's also very common to create a kind "application object" to hold all your global state, eg window.myApp = {} and then storing state as window.myApp.someVar = someValue. This helps with interoperability with other applications or frameworks, if that matters for you.

        Comment


          #5
          Ah...I see. I guess I thought only the defined properties and methods were allowed.

          So you can just create new "properties", so to speak, whenever you need to.

          Very cool.

          Sorry...learning JS and SC at the same time!

          Mike

          Comment


            #6
            My app is nearing completion, though, so my questions should abate soon. ;)

            The next leap will be creating an application framework for handling windows, logins, permissions, etc., like pallen did.

            I'm free to post mine, though...if I have the time to write it.

            Mike

            Comment


              #7
              I have read somewhere about a framework developed by pallen; but was that client-side or server-side ? I suppose security information should be handled on the server-side; and there are literally myriads of server-side frameworks out there, many of which take security into account ...
              Asked once more: Are there recommendations for SmartClient specific frameworks ? So to say a framework for the framework ?

              Comment


                #8
                Originally posted by Isomorphic
                It's also very common to create a kind "application object" to hold all your global state, eg window.myApp = {} and then storing state as window.myApp.someVar = someValue.
                What would be the equivalent in SmartGWT?

                Comment


                  #9
                  Generally a singleton. MyApp.instance().get/setSomeState().

                  Comment

                  Working...
                  X