sapui5 sap.ui.unified.Calendar How can we remove the SpecialDate - javascript

I have a small requirement in sap.ui.unified.Calendar, I want to remove the selected Special dates from Calendar. I'm trying with multiple options but still, I'm not able to achieve this.
On selection of a particular row, I'm going to call an OData Service and displaying the special dates which got highlighted in the Calendar.
Here my requirement is like if I select the 2 or more records in the table I should not display the special dates and the selected dates should get removed and the calendar should display the dates without any selections
I'm trying with removeStyleClass properties but it is not working. Here is my code.
if(sap.ui.getCore().roomsArr.length > 1){
MessageToast.show("Calendar Dates View will not get displayed for multiple record selections");
var oCal1 = that.getView().byId("myCalendar");
oCal1.removeStyleClass("sapUiCalItemType01");
}
Here i guess like, if i get the selected row Id's then i can remove the style class that is getting violet Background. But im getting dynamic date values so im not able to achieve this. Can someone help me to fix the issue?
Thank you in advance

Related

Google Sheets: "If item is "out of stock", then remove item from data validation list

I am have been trying to find a solution to my google sheet issue and have tried quite a few workarounds thus far, to no avail. I imagine I may need to use javascript to do the action, however, I am a beginner to javascript.
Here is what I would like the sheet to do.
Check 'sheet#2' and see if an item in the specified range is set to "out-of-stock"
Sheet#2
If the item in the range is set to "out-of-stock", then remove the item from the data validation list on 'sheet#1' and if it is "in-stock" then show the item on the data validation list.
Sheet#1
Here are some things I have tried thus far (if it helps):
on sheet#2 when an item is set to out stock, conditional format it, to make the cell text white (not visible). This works well for that particular sheet. however, data validation lists do not display the data it pulls exactly as it appears (so the text still shows on the dropdown list)
IF statement. I've tried a WHOLE LOTTA IF and IFS statements. This did not work, because you cannot have an if statement in the same cell as a data validation cell and b/c the cell name will likely need to be constantly changed in the future. (But I did, however, find a workaround to another issue I was trying to solve for a day now WHOOP WHOOP!)
Oh and I also tried conditional formating the cell so that if it ='s out of stock white out the cell... however I get an error that conditional formatting does not work across 2 sheets
... so yeah if anyone may know of a solution to get this to work I will forever appreciate it! I'll keep scouring google for solutions in the meantime.
For the sake of simplicity, I've created a sample spreadsheet with two sheets: Sheet 1 and "Stock".
Sheet 1
Stock
Solution
I've created an Apps Script function to set the Data Validation as you have specified.
I've used the Javascript filter and map functions to simplify getting the data, but basically:
I get all the rows from the Stock sheet and load them into "memory"
I then discard from "memory" the rows that do not have their second column (row[1]) equal to "In Stock".
Then I get the remaining rows and grab only their first column (row[0]).
I then create a new DataValidation object (with it's builder) that uses the list we got above and assign it to the range I want to have validated.
//VARIABLES
var rangeToValidate = "B2:B";
var validateSheet = "Sheet1";
var optionSheet = "Stock";
function refreshDataValidation() {
var inStockOptions = SpreadsheetApp.getActive().getSheetByName(optionSheet).getDataRange().getValues()
.filter(function (row) { return (row[1]=="In Stock")})
.map(function(row) {return row[0]});
SpreadsheetApp.getActive().getSheetByName(validateSheet).getRange(rangeToValidate)
.setDataValidation(
SpreadsheetApp.newDataValidation().requireValueInList(inStockOptions).build()
);
}
Also, by adding some code with Apps Script, the sheet will make sure that your drop-down is always up-to-date.
I am refreshing the drop-down every time the sheet is opened and every time there is an edit to the Stock sheet on the B column.
//When the sheet is opened, refresh the data validation
function onOpen(e) {
refreshDataValidation();
}
//When a change is made to the Stock sheet, also refresh validation
function onEdit(e) {
var range = e.range;
if (range.getSheet() == SpreadsheetApp.getActive().getSheetByName(optionSheet) && range.getColumn() == 2) {
refreshDataValidation();
}
}
Hope this helps!
Okay guys I found a solution, anyone visiting this post in the future here you go!!!
So yes, you can use the script as provided above. However, if you already have other scripts, data validations, and other formatting's going then ,like me, you may actually run into a lot of errors and conflicting issues.
As a workaround here is what I did to get everything to work properly. you will need a total of 3 sheets: a main sheet, a 2nd sheet with your options, and a 3rd sheet to house the pulled data.
On the 2nd sheet, be sure to have a column that shows if the item is "in-stock" or "out-of-stock" (I did it as a dropdown menu)
On the 3rd sheet select the cell where you would like the data to show. And use the filter function formula to pull only the rows from sheet 2 that are equal to "in-stock"
Formula syntax: =(FILTER (range, condition1, [condition2, ...])
My Formula: =FILTER( sheet2!G3:R5, sheet2!I3:I5 <> "out-of-stock")
sheet2!G3:R5 = the range of rows/columns I want it to pull from.
sheet2!I3:I5 = the column I would like it to look for the words "in stock" or "out of stock" in
<>"out-of-stock" = show me the data if a cell in column I3 does not equal "out-of-stock" (meaning, only show in-stock options)
As you can see the formula will pull/show you all the rows that = "in-stock", anything you have set to "out-of-stock" will not show on the 3rd sheet.
Last part,
On the main sheet select the column you would like for your drop down list to show in. Add the data validation being sure to list from the range on the 3rd sheet (not sheet 2).
Now you can hide the 3rd sheet as you should no longer need it, unless debugging.
Finally, As you can see now, my main sheet will only show the items in the drop down list that are set to "in-stock", out of stock options are removed from drop down list, unless set back to in-stock. (see how pic3 only shows 2 options in drop list, although pic1 shows that there are 3 options available).
so now basically if I change an item to "out-of-stock" on the 2nd sheet, the item will be removed from drop-down list on the main sheet, AND if I change an item to "in-stock" the item will be added/displayed on the drop list. The 3rd sheet is no longer needed. This solution is perfect if you have multiple users and would only like for them to be able to select an option that is "in-stock"!
Hope this helps someone!!! And thank you to the people of above who gave other possible solutions!!

Servoy - Getting all data from db table to display as list

I am relatively new to Servoy and Javascript so that might be why i can't get this to work but here goes:
I am trying to get a label to display all of the data from a specific column from my database table in a list.
I tried to add a dataProvider but that adds only one record per page.
I need the items to be listed below each other so it makes it easier for me to see.
I have also tried adding:
function firstName(){
foundset.loadAllRecords();
return;
}
and setting it as an onRender to see if that displays everything
Thanks in advance
If you look for the answer then here it is:
Use a label and set the text of the label to
%%list_display%%
Set your form layout to Tableview
The answer for above was using Servoy Developer and PostgresSQl

calendar as a popup in ag-grid cell

I am using ag-grid to display a list of columns. One of the columns contains the date section.
User should be able to edit the row and use calendar to select a particular date. Once a date is selected, it will get updated in the cell.
Any idea how to make it achievable ?
As per Ag-grid, we have to use cellEditor rather than cellRenderer to edit a cell and show calendar at every cell for selection of a date
https://www.ag-grid.com/javascript-grid-cell-editing/index.php
They have given few examples of how we can use Celleditor. Can someone please let me know how to use calendar for each cells of the 'date' column.
Got the following answer from ag-grid team
editing of dates is not provided out of the box. you will need to create your own cell editor for dates.
details on how to do cell editors is here:
https://www.ag-grid.com/javascript-grid-.../index.php
I use bootstrap, and this has property type="date". I have one list "ListDataSource", this has one file call celDate and contains this html:
When i send this list to api.setRowData(ListDataSource), the grid create the date input.
See you.

Setting Default Dynamic Values in Select2 2.4.0?

I'm currently using the most up-to-date version of Select2. The select2 box is used to display a list of skills. I am trying to set the default values (for when it's opened) to contain the current skills. I have the information in proper format, I just cannot understand how to set it. The closest I've gotten is using:
//b is array containing list of user selected options
//#e1 is select2 id
for($i=0;$i<b.length;$i++) $('#e1').val(b[$i]).trigger("change");
However, this only displays the LAST option. Which I think is because I'm not allowed to set it in a loop. However I'm unsure how else to do it??
Any current solutions are invalid as of Select v2.4.0 as initSelection and .select2("val", data etc.) was removed.
Any help is appreciated.
My solution was actually very simple and avoided for loops all together.
$('#e1').select2({
//info
}).val(b).trigger("change");
val() in jQuery also accepts arrays.

Knockout with Jquery UI datepicker date display

Please see this link for details http://jsfiddle.net/pakpatel/5p6Uz/4/
Can we do the range in Datepicker, If first date choose [ 10/12/2012 ] then second date shouldn't be before 10/12/2012, Customer can select date after ex.[10/13/2012] in datepicker.
Could anyone explain me how to implement. Thanks in advance.
By using the previous row's data as the new min, it makes it challenging.
Working demo is at http://jsfiddle.net/photo_tom/5p6Uz/24/
There were two things that were required.
Added a computed observable to pass the previous row's choosedate value to the current row.
Added a new minDate binding to set the mindate option on the date picker.
This is not a completed fiddle. It doesn't properly handle adds or deletes. This is because the ko.computables need to be rebuilt.
EDIT:
Updated to handle add / delete methods. Interesting problem, trying to transfer information between two different rows in the table. Good challenge.
Soution at http://jsfiddle.net/5p6Uz/34/.

Categories