delete rows based on checkbox selection in slickgrid - plugins

i am taking help of this example: http://mleibman.github.com/SlickGrid/examples/example-checkbox-row-select.html and add a checkbox column to my grid and assign unique_id value of my record to the id of checkbox column i am getting checked columns number using grid.getSelectedRows();
it gives me a index number of row. how can i get id of this selected rows in slickgrid? please help me if anyone have any idea.

var selectedrows = grid.getSelectedRows();
for(i=0;i<len;i++){
var d = grid.getData().getItem(selectedrows[i]);
if(d != null && d != 'undefined'){
dataView.deleteItem(d.id);
grid.invalidate();
grid.updateRowCount();
grid.render();
}
}
It removes rows from grid. not from server side.

Related

How to find the column based on the minimum value and the position

A new column should be added as a function of the condition.
Match Condition
eg : ID 1877
1.) In the id group, the minimum value of tho_cw_diff should be checked and Rail position of thor_pos/CW_pos should be same.
eg : ID 7931
2.) If the rail position is not the same for the minimum tho_cw_diff value, check for the other minimum value in group ID that the rail position thor_pos/CW_po is the same.
eg: ID 8880
3.) If all the rail position is different for the group ID, select the minimum tho_cw_diff value.
According to these three conditions, the new column must be updated.
Sharing screenshot data of the expected outputs below
You can try this one.
VAR ID = [ID]
VAR CV_POS = [CV_POS]
VAR tmpTbl =
CALCULATETABLE(
tbl
,ALL()
,tbl[ID] = ID
,tbl[THO_position] = CV_POS
,tbl[CV_POS] = CV_POS
)
VAR Result =
IF(
ISEMPTY(tmpTbl)
,MIN(tbl[THO_CV_DIFF]) -- may be you can write just [THO_CV_DIFF]. I didn't check
,MINX(tmpTbl,[THO_CV_DIFF])
)
RETURN
Result
I didn't check, so come with a feedback.
By the way, you can add you table by using of following symbols: "|" and "-"
myColumn1
myColumn2
A
1
B
2

Repeat the value from left table if date from right table falls between start date and end date

I would like to join my two tables on [Group] and [YearMonth] Dates. Where [YRMO_NB] from Table 2 falls between [ENR_START] AND [ENR_END] from Table 1 then repeat the value of column [PHASE] for each related row, just like the second picture last column = [PHASE] and leaves unmatched rows blank.
I did this which only gives me exact matches:
ON A.GROUP = PHASE.GROUP
AND A.YRMO_NB = PHASE.ENR_START
Table 1
Table 2
Is there an easy way to do this ?
Thank You!
I figured it out
ON A.GROUP = PHASE.GROUP
AND A.YRMO_NB >= PHASE.ENR_START
and A.YRMO_NB <= PHASE.ENR_END

PowerBI : Filter by interval

I have a table with columns "date_start" and "date_end".
In the report I want a datepicker that filters the rows where the picked date is between these two columns.
But I have no idea how to do it, and I can't find anything on the internet...
Do you have any idea?
Create a measure and put it to visualization. Here example (2 disconnected table)
PickThis = var __selectedDate = SELECTEDVALUE('Calendars'[Date])
return CALCULATE(COUNTROWS('Employ'), ALL('Employ'[From],'Employ'[To]), 'Employ'[From] <= __selectedDate && ('Employ'[To] >= __selectedDate || ISBLANK('Employ'[To]) ))
dummy data:
Output:

how to retrieve a column's values in order to update a column total

I have a pinned row that acts as a column's total, which works fine using gridOptions.pinnedBottomRowData. I need to update this value when the columns' cells' values change but I cannot find a means of accessing the column values to do so. What's the best means of updating a column total when it's columns' cells' values change?
You can calculate the total on cell value changed or value setter function.
this.gridOptions.onCellValueChanged = function (event) {
if (event.colDef.colId == "ColumnName") {
//Logic to update the total row value
total = total + event.data[event.colDef.field]
}
}

Delete Column from spreadsheet using OpenXML

I was wanting to delete a column using openxml, I am able to clear the contents of the cell, but have been unable to find documentation to delete the column as to shift the other cells left when the column is deleted. How may I delete the column using openxml where it will shift the cells to the left?
I discovered that OpenXml has no way to delete a column on its own. Therefor to solve my problem I wrote a function that first removed the contents of the cells in the column I was deleting and then to set the cell reference of the columns that came behind the column I was deleting up a column.
You can iterate for each row and remove the cell you need
private void RemoveCell(int rowIndex, int colIndex)
{
SheetData sheetData = _worksheetPart.Worksheet.GetFirstChild<SheetData>(); // get the sheet
Row row = sheetData.Elements<Row>().FirstOrDefault(r => r.RowIndex == rowIndex);
if (row != null && row.Count() > colIndex)
row.RemoveChild(row.ElementAt(colIndex));
}