Remove focus from the record in listbox until selected

Posted by: nivishapanwar on 2 March 2021, 10:16 am EST

    • Post Options:
    • Link

    Posted 2 March 2021, 10:16 am EST

    Hi,

    I am using wijmo listbox with typescript code. I am using a textbox and wijmo listbox. The issue I am facing is whenever I add a record to listbox from textbox , that record is always on focus. I want to focus the record only when its selected.How can I resolve this?

    I have attached a file .

    Code=>

    fullname: string;

    addRecord() {

    this.recordData.push(this.fullname);

    this.name = new CollectionView(this.recordData);

    this.saveListBoxData();

    }

    updateRecord() {

    //let lb = this.name1;

    let textBoxValue = this.fullname || “”;

    if (textBoxValue) {

    let cv = this.ListData.collectionView;

    cv.items[this.ListData.selectedIndex] = textBoxValue;

    cv.refresh();

    this.saveListBoxData();

    }

    }

    removeRecord() {

    let lb = this.ListData.collectionView;

    lb.items.splice(this.ListData.selectedIndex, 1);

    lb.refresh();

    this.ListData.selectedIndex = -1;

    this.fullname = ’ ';

    this.saveListBoxData();

    }

    displayListBoxValueInTextField(listBox) {

    this.fullname = listBox.selectedValue;

    }

    HTML-<input type=“text” [(ngModel)]=“fullname”

    style=“width: 540px; height: 30px; margin-left: 30px;”>

    <wj-list-box #ListData [itemsSource]=“name” (initialized)=“initListBox(ListData)”

                                (selectedIndexChanged)="displayListBoxValueInTextField(ListData)">
                                <ng-template wjItemTemplate let-item="item" let-itemIndex="itemIndex">
                                    {{item}}
                                    <div class="wj-glyph">
                                      <span class="wj-glyph-drag"></span>
                                    </div>
                                  </ng-template>
                            </wj-list-box>
    

    Thank You.

    Regards,

    Nivisha

  • Posted 2 March 2021, 10:19 am EST

  • Posted 3 March 2021, 8:22 am EST

    Hi Nivisha,

    You can save the currently selected item before pushing the new item and set it again after the addition is complete:

    addRecord() {
        let item = this.ListData.selectedValue;
        this.recordData.push(this.fullname);
        this.name = new CollectionView(this.recordData);
           this.saveListBoxData();
        this.ListData.selectedValue = item;
      }
    

    Regards,

    Ashwin

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels