Announcement

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

    Focus and select in grid editing

    Hi,
    I have a problem in grid editing where when I click on an edit item in a row which is in edit mode (shows editors for the cells) that the value in the edit item gets selected. I have debugged a lot of things and tried different things. it seems that the element.focus() also selects the value (were element is the native html element).

    It is probably related to some custom code I have. But, when i try the smartclient demo row editing, then I see somewhat of the same, when I click in a edit item in a row (in edit mode) then I briefly see that the complete value gets selected before the cursor is placed in the correct location in the edit item.

    So it seems that Smartclient repairs the select (if selectOnFocus is false), and my code kind of prevents this 'repair'.

    Does this make sense somehow? (I hope)
    I hope you have any pointers I can check to solve this. Thanks!

    gr. Martin

    #2
    Not really clear on what you want - selectOnFocus is on by default because it's highly desirable and is how most grid-like editing interfaces work. Why would you turn it off?

    And, if you really want to turn it off, can you explain how to reproduce a problem where selection happens even though you've turned it off? Be very specific about browsers and versions as well please.

    Comment


      #3
      It is indeed a discussion if selectOnfocus is desirable. However for mouse clicks on a field, for example if you click on a date field on a specific location you want to change (the month) then it makes sense to not select the complete value but put the cursor where the user wants.

      Where is selectOnFocus set to true? in the docs it is false/null, in the demo it is not enabled either it seems.

      I am using chrome 12 on Linux 64 bit, ubuntu

      gr. Martin

      Comment


        #4
        To clarify, the browser has a default behavior of doing select on focus that matches what you want. This is described in the docs for the SmartClient selectOnFocus setting:

        Note that this flag affects only programmatic focus. It's the normal behavior of text
        fields to select all text if the user navigates into them via keyboard, or if the user
        navigates via mouse, to place the text insertion point at the mouse click, and
        SmartClient preserves these behaviors. <code>selectOnFocus</code> if only needed for
        cases like a form within a pop-up dialog that should have the first field selected.
        So once again, if you're seeing something undesirable, be specific about how exactly to reproduce it. And, if you find that it's Chrome/Ubuntu only, you should consider whether it matches the platform (Ubuntu's) default behavior elsewhere, because we are intentionally not overriding that.

        Comment


          #5
          Hi,
          I do this in my code:
          - open a grid and start editing a row
          - click on a date or other field in the middle of the field with the mouse
          - the complete value gets selected

          When I check the SC demo, I see the following:
          - open a grid and start editing a row
          - click on a date or other field
          - I see briefly that the complete value gets selected and then the cursor is placed in the correct place (so the complete value gets deselected)

          As my code does not work, my guess is that I am somehow breaking the SC code which prevents/repairs the complete selection of the value and puts the cursor in the right place. I hope for some pointers which can direct me in the right place to look for a solution/workaround.

          gr. Martin

          Comment


            #6
            As the docs say, unless you set selectOnFocus, there's no SmartClient code running in this instance, we're just allowing the native browser behavior to happen. So if you're getting something other than the native browser behavior, you might be setting selectOnFocus, or doing something directly to the DOM or via CSS that causes this effect - if you isolate it to something that suggests that SmartClient is involved, we'll take a look.

            Comment

            Working...
            X