Skip to content

Infragistics Community Forum / Web / Ignite UI for Angular / Select igx Grid cell text with row edit

Select igx Grid cell text with row edit

New Discussion
Sean Connor
Sean Connor asked on Mar 30, 2020 12:54 PM

Hi, 

I am using Igx-grid in one of my forms and I have implemented the functionality to edit row by clicking in different cells. 

I want to select the text of editable cell because Its more easy this way to add/edit as on cell edit for user.

Whenever  user tries to edit cell, It shifts the control next to value "0" so the user needs to come back for entering decimal value. 

That would be nice if you guys can get me a solution. 

Thanks 

Sign In to post a reply

Replies

  • 0
    Hristo Anastasov
    Hristo Anastasov answered on May 27, 2019 9:27 AM

    Hi Sean,

    I am not quite sure that I got your issue completely right. Do you mean that when the cell enters edit mode, the cursor goes to the beginning of the value, while you want it to be at the end?

    • 0
      Sean Connor
      Sean Connor answered on May 27, 2019 9:32 AM

      When the user enters in edit mode, It shifts the focus to right side of zero when It should select zero to enter the value and then it should override it but its not happening.

      • 0
        Hristo Anastasov
        Hristo Anastasov answered on May 29, 2019 1:07 PM

        Hi Sean,

        You can easily achieve this requirements using the igxFocus and igxTextSelection directives. What they do is: igxFocus will focus the element that it is applied to, and igxTextSelection will select the content of the element (this is not supported on every element).

        To achieve the desired in the grid, you need to provide an ng-template for the column editor and apply the directives:

        
         
          
           
          
         
        

        Please enter edit mode for the UnitsInStock column in this Editing example and let me know if you have further questions, I will be glad to help.

      • 0
        Sean Connor
        Sean Connor answered on May 29, 2019 3:18 PM

        Hi Hristo, 

        I have used the example you have created for more help to select text and set the focus as well. Apparently It is performing both of the functionalities but I am using an event "onRowEdit()" to get the edited values. It used to give me newvalue of the row and oldvalue of the row as well before using "ng-template" but now It just gives me oldvalue and the newvalue is null. I was performing some validations on data while editing the row but I am not able to do that. 

        I tried to remove the igxCellEditor from ng-template and then it gives me the values but at that point focus is not set and text is not selected for editing purpose. 

        Please advise me If there is a work around to get this done, I shall really appreciate that.

        Sean

      • 0
        Hristo Anastasov
        Hristo Anastasov answered on May 30, 2019 7:31 AM

        HI Sean,

        When using the hooks of the grid, like the onCellEdit, onRowEdit, we need to bind the editor to the cell.editValue, instead of cell.value:

        [(ngModel)]="cell.editValue"

                
                    
                        
                    
                

        I have updated the Editing example. Please let me know if you have further questions, I will be glad to help.

      • 0
        Sandeep Varma
        Sandeep Varma answered on Mar 30, 2020 11:53 AM

        Hi Hristo,

        I am able to do textSelection when type is text using igxTextSelection directive, what shall be done when input type is number?
        Please advice how can achieve this

      • 0
        Hristo Anastasov
        Hristo Anastasov answered on Mar 30, 2020 12:54 PM

        Hi Sandeep,

        For numeric input types, only selection of the whole content is supported (reference). It also states that

        "If you wish to select all text of an input element, you can use the HTMLInputElement.select() method instead."

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Sean Connor
Favorites
0
Replies
7
Created On
Mar 30, 2020
Last Post
5 years, 11 months ago

Suggested Discussions

Tags

Created by

Created on

Mar 30, 2020 12:54 PM

Last activity on

Mar 30, 2020 12:54 PM