question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I need to select on init some rows, so I set on init some rows to this.selected. All good, but when I click + shift I unselect rows, Event selected says that I select none;


     <ngx-datatable
        #table 
        class="material"
        [rows]="rows"
        [columns]="columns"
        [selected]="selected"
        [selectionType]="'multi'"
        [columnMode]="'force'"
        [headerHeight]="24"
        [footerHeight]="0"
        [rowHeight]="40"
        [scrollbarV]="true"
        [scrollbarH]="false"
        [messages]="{emptyMessage: 'No items have been added to the collection'}"
        (select)='onSelect($event)' 
        (page)='onPage($event)'
        (recalculate)=recalculate($event) >

         <ng-template #editTmpl let-value="value" let-row="row" let-i="index" >

          <span 
                  *ngIf="!editing[row.$$index + '-name']">
                  {{value}}
            </span>
            <input #input autofocus type="text"
                  (blur)="updateValue($event, 'name', value, row, input)" 
                  (keyup.enter)="updateValue($event, 'name', value, row, input)"
                  [hidden]="!editing[row.$$index + '-name']" 
                  [value]="value"
                  [class.error]="row.error"
            />
            <img class="rename-icon" src="assets/images/rename.png" 
                  (click)="onRename( input, row )"
                  [hidden]="!checkingPermission(row, 'Update')"   />
         <!--         editing[row.$$index + '-name'] = true-->

         </ng-template>

         <ng-template #dateTmpl let-value="value" let-row="row" let-i="index">
           <time>{{value | dateFormat }}</time>
         </ng-template>

          <ng-template #boolTmpl let-value="value" let-row="row" let-column="column" let-i="index">
              <img class="validStatus-img" src="./assets/images/{{value?column.trueImg:column.falseImg}}"  />
              <span>{{value ? "Ok" : "Invalid"}}</span>
          </ng-template>

      </ngx-datatable>

Datatable 8.0.0 Angular 4

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:17 (1 by maintainers)

github_iconTop GitHub Comments

20reactions
DrackThorcommented, Feb 10, 2020

I found a way to make it work for my scenario - the key is to specify [rowIdentity]="rowIdentity" at the datatable html object. That way the component can compare the row in [rows] and [selected] and REALLY mark the “pre-selected” rows. Works like a charm, but the documentation is quite shallow on this (https://swimlane.gitbook.io/ngx-datatable/api/table/inputs#rowidentity).

1reaction
davidoweencommented, Nov 7, 2018

I have solved it by searching the DOM for the checkbox and clicking on them. Is working

El mié., 7 nov. 2018 19:48, Tim Schmidt notifications@github.com escribió:

I am having the same problem when storing the selected array in service to preserve it when users navigate to other views.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/swimlane/ngx-datatable/issues/700#issuecomment-436735032, or mute the thread https://github.com/notifications/unsubscribe-auth/ATkImK1k9UDpZNmdkkaruW3UinNtDVTeks5usysVgaJpZM4NFFyM .

Read more comments on GitHub >

github_iconTop Results From Across the Web

How initialize dropdown (<select/>) with preselected value ...
So I've got dropdowns defined like that with selected option specified for preselecting the value from DB. <select id='selectId'> <option value= ...
Read more >
Wrong option selected on init (x-for usage in select) · Issue #495
There are some issues with which option is selected when select's options are generated with x-for. See pen for demo.
Read more >
init(_:selection:content:) | Apple Developer Documentation
A string that describes the purpose of selecting an option. selection. A binding to a property that determines the currently-selected option. content. A ......
Read more >
Initialize select option - Get Help - Vue Forum
I want to initialize my Game in my GameList of my select with an object “selectedGame” located in my store vuex but with...
Read more >
Select - Materialize
Select allows user input through specified options. ... Remember that this is a jQuery plugin so make sure you initialize this in your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found