Kendo Grid : Hiding a Group Header When value is empty - kendo-grid

Is there a way to check that if the group value that is returned is "null" and then hide the group header and expand/collapse button if that is the case?

There is no easy way to go about this. However you can try this in your grid:
dataBound: function (e) {
if ($('#grid').data('kendoGrid').groupable.dataSource._group.length > 0) {
$('#grid tbody .k-grouping-row').filter(function (index) {
return $(this).find("p")[0].innerText.slice(-1) === ":";
}).hide();
$('tr td:empty').parent().hide();
} else {
$('tr td:empty').parent().show();
}
}
Every time you group a column, it calls the dataBound event. First, I check the grid for its grouped columns.
If the grid is being grouped, I find all the group header rows that end in : (meaning that the value being grouped on was empty or null and the label would show Contact Name: for example). I also find all the data rows that have an empty cell, and I hide both the header and data rows.
However, when ungrouping, I have to reveal data rows with null/empty cells again. The header rows are removed automatically. You can check this out in action here --> jsFiddle Demo. Edit the first row's name to be nothing, and then group. It will not show any empty groupings.
This is very hacky and unknown problems could arise, but hope it helps though!

Related

How to clear cells if ISBLANK?

I want to add clearing function. If "B1" is blank, then clear C1,D1,E1,F1;
But I don't know how I can do it. I tried custom function in formatting, but not works.
Can u help me?
The simple answer to your question is as follows:
function myFunction() {
let your_sheet = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/your_sheet_id').getSheetByName('Sheet1')
let cell_check = your_sheet.getRange('B1');
if(cell_check.isBlank()) {
your_sheet.getRange('C1:F1').clearContent();
}else{
console.log('not empty')
}
}
But I would probably advise considering the use of numbered ranges instead of named ranges as it will be easer to reason about at scale if you are running through multiple rows.
function myNumberedRangeFunction() {
let your_sheet = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/your_sheet_id').getSheetByName('Sheet1');
let cell_check = your_sheet.getRange(1,2);
/* getRange(
1, the first row,
2, is the second column
)
*/
if(cell_check.isBlank()) {
your_sheet.getRange(1,3,1,4).clearContent();
/* getRange(
1, the first row,
3, the third column,
1, get one row,
4, get four columns
)
*/
}else{
console.log('not empty')
}
}
Typically, if I am manipulating a large spreadsheet, I will pull the entire spreadsheet data_table = your_sheet.getRange(1,1,1,1).isBlank() ? [] : Array.from(your_sheet.getRange(1,1,your_sheet.getLastRow(),your_sheet.getLastColumn()).getValues()); and convert it to a table array that I can analyze and manipulate all at once and then just place the changes all at once with
your_sheet.getRange(1,1,data_table.length,data_table[0].length).setValues(data_table)
You can hide, but not clear, the values in columns C:F with this conditional formatting custom formula rule:
=isblank($B1)
The rule should set the text color to match the cell fill color, making the value in the cell "invisible".

Sorting on empty kendo grid shows old data

I have a dropdown(having 2 values - Employee and department) and two kendogrids(emp grid and dept grid), on change of dropdown I am enabling/disabling grid based on dropdown value and also clearing datasource of both grid, when I select employee in dropdown and sort employees based on name it gives results, when i change dropdown value to 'Department' it disables employee grid and shows 'No data found' in employee grid,but when I clicked on EmpName column i still got the previous results. I have added dropdown change sample code below.
var ddlvalue = $("#drpmodule").data("kendoDropDownList").text();
$("#EmpGrid").data("kendoGrid").dataSource.data([]); //Clear EmpGrid DataSource
$("#DeptGrid").data("kendoGrid").dataSource.data([]); //Clear DeptGrid DataSource
if (module == 'Employee') {
$('#DeptGrid').addClass('k-state-disabled');
$('#EmpGrid').removeClass('k-state-disabled');
}
else if (module == 'Department') {
$('#EmpGrid').addClass('k-state-disabled'); //shows no data found in EmpGrid, but clicking on column header gives results
$('#DeptGrid').removeClass('k-state-disabled');
} else {
$('#EmpGrid').removeClass('k-state-disabled');
$('#DeptGrid').removeClass('k-state-disabled');
}
I am not getting why Employee grid is showing previous/old data even after 'No data found' records(on changing dropdown).
It would be nice to see how the datasource is configured.
As it is I can assume that maybe when you are filtering, the datasource is fetching data. It would explain why you see data on filtering the empty grid.
Maybe hiding the disabled grid could be a solution : $('#EmpGrid').hide();
Then display it again $('#EmpGrid').show();
By hiding/showing the grid you don't need to empty the grid anymore.

PrimeNG p-orderList disable multiple selection of items

I am using PrimeNG's p-orderList. By default, the metaKeySelection attribute is true which implies that a metaKey(ctrl key) is needed to be pressed to select multiple items. I was rather looking for a way to completely disable selection of multiple items. I should be able to select ONLY ONE item in the ordered list.
There is no metaKey attribute available for p-orderList. Can anyone help me with this?
<p-orderList [value]="policyList" [listStyle]="{'min-height':'calc(100vh - 325px)'}" (onSelectionChange)="onSelectionChange($event)">
<ng-template let-policy pTemplate="policy">
<span>{{policy}}</span>
</ng-template>
</p-orderList>
PS: onSelectionChange($event) is triggered every time you select items from the ordered list. $event.value contains the array of the items.
There is no easy flag for it but it can be achieved through calling a function that basically replaces the entire selection array with just the original selected row.
You will need a variable to store the previous value for comparison.
onSelectionChange(event) {
if (event.value.length === 1) {
this.tempValue = event.value[0];
}
else {
event.value = [this.tempValue];
}
}
Can also be simplified by passing event.value to the function
(onSelectionChange)="onSelectionChange($event.value)">
What about the metaKeySelection input property? (as shown here)
<p-orderList [metaKeySelection]="false" [value]="policyList" [listStyle]="{'min-height':'calc(100vh - 325px)'}" (onSelectionChange)="onSelectionChange($event)">
<ng-template let-policy pTemplate="policy">
<span>{{policy}}</span>
</ng-template>
</p-orderList>

How to check in sikuli that image is exist in screen or not and perform if else condition on that result

I am trying to automate a desktop application in sikuli. What i am doing copying data from from existing user and creating new user using some of that data. In form there are two check boxes. If that check boxes is ticked for existing user, then while creating new user i need to check the text box. for that am taking checked text box image and giving in if condition. If checked text box image is there in that page i will carry value 1 to a variable else value will be 0. according to that value am performing check uncheck function in new user creation page. But the issue what i am facing is, am not able to check if the image exist in that page or not in sikuli. Please anybody help me. my code is giving below
int bomanager=0;
int boswitchboard=0;
System.out.println("boswitchboard value before assign it to 1" + bomanager);
if (screen.exists("images/backofficeswitchboardwithtick.png") != null)
{
boswitchboard=1;
System.out.println("boswitchboard value after assign"+boswitchboard);
}
System.out.println("bomanager value before assign it to 1" + bomanager);
if(screen.exists("images/backofficemanagerwithtick.png") != null)
{
bomanager=1;
System.out.println("bomanager value after assign it to 1"+bomanager);
}
then using this value need to perform below function.
System.out.println("Before condition" + bomanager);
if (bomanager ==0){
screen.click("images/backofficemanagerwithtick.png");
}
screen.setAutoWaitTimeout(10);
System.out.println("Before condition" + boswitchboard);
if(boswitchboard==0){
System.out.println("Inside To tick Condition" + boswitchboard);
System.out.println("Ticking the SwitchBorad when itsnot already ticked");
screen.click("images/backofficeswitchboardwithtick.png");
}
I'm asssuming you're looking to use "if exists" method here
if exists(img, timeout):
click(img)
else:
....
with the method exists() I usually use:
if(exists("yourUrlImage")!=null):
(do something when exists)
else:
(do another thing when not exists)
Because that will return a "match" object.
Hope this helps

AdvancedDataGrid: dataTip = headerText

I have a pretty straightforward question which google fails to give me the answer to :
I have an AdvancedDataGrid where i build the columns dynamically (variable number of columns) in ActionScript, and i want the dataTip to display the column headerText when the user hovers over a cell. Adobe's example dataTipFunction:
private function tipFunc(value:Object):String
{
if (value is AdvancedDataGridColumn)
return "Column Name";
// Use the 'name' property of the data provider element.
return "Name: " + value["name"];
}
But in this case the value is only an AdvancedDataGrid column if the user hovers over a column header? I want the dataTip to always show the headerText for that column. So if i have to use this function, then how do i get the column headerText for a cell?
And as i understand the dataTipField i can't really use it to statically equal column.headerText (dataTipField = headerText).
Anyone have any pointers on how i can achieve this? It seems like a really easy task, still i can't seem to find out how :)
You can use a different function per column, which could be anonymous:
<AdvancedDataGridColumn dataTipFunction="{function(value:Object):String{return 'Data Tip'}}" ... />