How mark selected item from the datatable PrimeNg? - primeng

I use the selectionMode = "multiple" option of datatable, How mark selected item from the database
Template:
<p-dataTable [value]="userLanguage" dataKey="key">
<p-column [style]="{'width':'38px'}" selectionMode="multiple"></p-column>
<p-column field="languageName" header="Idioma"></p-column>
<p-column field="languageId" header="Código"></p-column>
</p-dataTable>

selectionMode="multiple" needs to go into your p-dataTable line, not on the column. Also, you need to define what model you want to store your selected items, such as [(selection)]="selectedLanguages" on the same line. To display certain items as selected, you need to add the languages to the selectedLanguages array

Related

PrimeNG p-datatable sort indicator overlapped

I creating a table with sortable column. This is my code:
<p-dataTable [value]="list">
<p-column field="name" header="name" sortable="true">
</p-column>
<p-column field="value" header="value" sortable="true">
</p-column>
</p-dataTable>
The problem is that the sortable indicators are overlapped in the first column, so on click it works on second column only.
With many other column it works in the same way. It seems like all the indicators are overlapped in the same place (see picture).
Any suggestions?
Thanks

Capturing checkbox selection event in prime dataTable

In the prime datatable I have a checkbox to select multiple rows. When I select or unselect the checkbox, all the rows get selected/unselected correctly. On selecting or unselecting the checkbox I want to disable few buttons at the top. Hence I need help in knowing the attribute to capture selection.
<p-dataTable>
<p-column selectionMode="multiple">
</p-column>
</p-dataTable>
use onRowSelect and onRowUnselect events
for example :
(onRowSelect)="updateSelected($event)" (onRowUnselect)="updateSelected($event)"
onHeaderCheckboxToggle did the trick.

View based NSTableView checkbox

I have an NSTableView that's view based, not the old cell based, and I'm doing everything via bindings. In one of my columns I now want a checkbox. I dragged a checkbox button (not a checkbox button cell) inside of the column's "Table Cell View".
Then I deleted the "Table View Cell" and its child. When I run, I don't see any checkboxes in the column. What's the right way to do this?

How to hide Item in RepositoryItemComboBox?

Hi I am using devExpress on winform.
I have a list of items wholeList = {Item1, Item2, Item3, Item4,Item5,Item6},
and I have another two lists: ActionAList = {Item1, Item3, Item5}, ActionBList = {Item2, Item4, Item6}.
I have a grid view on my form. And I have two columns "Action" and "Item" on this grid. Each column has a repositoryItemComboBox as in-place editor.
In the dropdown of "Action", I have "ActionA" and "ActionB". In the dropdown of "Item", I have all the 6 items Item1 to Item6. When I select ActionA, I want Item dropdown only displays Item1, Item3, and Item5. The same when I select ActionB, I want Item dropdown only displays Item2, Item4 and Item6.
I think when user selects different Action (either A or B), I can clear the repositoryItems in Item dropdown, and add either ActionAList or ActionBList back to repositoryItem. But I feel uncomfortable, because it is possible at this point of time, the available items in Item dropdown are only Item1,3 and 5, but another row may still keep ActionB and Item2.
I wonder what would be the best way to archive this requirement.
I also think of whether we have any method to hide some items in the whole list.
So when the user open the editor of Item dropdown. According to the current row's action value, I may just display items in ActionAList or in ActionBList. But I am not able to find such property when I create ComboBoxItem or ImageComboBoxItem.
Thanks for any input!
Firstly, please remember that repositoryItems are only templates to construct editors for each row in GridView. The only way to control editors on cell basis is handling CustomRowCellEdit event (where you can choose existing editor or create custom editor).
Secondly, you have to handle CellValueChanged event to clear column 'Item' every time the user changes value in column 'Action' in order to avoid situation you've described (Item from ActionBList when Action = A).
Regards,
Maciej Nowicki

DataGridView column of type DataGridViewCheckBoxCell is constantly readonly/disabled

I am using a .NET Windows Forms DataGridView and I need to edit a DataBound column (that binds on a boolean DataTable column). For this I specify the cell template like this:
DataGridViewColumn column = new DataGridViewColumn(new DataGridViewCheckBoxCell());
You see that I need a CheckBox cell template.
The problem I face is that this column is constantly readonly/disabled, as if it would be of TextBox type. It doesn't show a checkbox at all.
Any thoughts on how to work with editable checkbox columns for DataGridView?
Update: For windows forms, please.
Thanks.
Well, after more than 4 hours of debugging, I have found that the DataGridView row height was too small for the checkbox to be painted, so it was not displayed at all. I have found this after an accidental row height resizing.
As a solution, you can set the AutoSizeRowsMode to AllCells.
richDataGrid.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
Instead of trying to create the column in code, click on the tiny arrow in a box at the top right of the DataGridView control, and select "Edit Columns..." from the menu that appears. In the dialog box, click the Add button, then choose the "Databound column" option and pick the boolean column you're binding to.
Create a TemplateField and bound the id to it, something like this:
<asp:TemplateField HeaderText="Whatever" SortExpression="fieldname" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:CheckBox runat="server" ID="rowCheck" key='<%# Eval("id") %>' />
</ItemTemplate>
</asp:TemplateField>

Resources