How to read scorecard items programmatically? - sharepoint

I managed to get the scorecard item using the BIMonitoringAuthoringServiceProxy webservice, but I have no idea how can i go through the items that it holds (am unsure of the terminology that should be used for the items that are shown in the scorecard).
I need to read these values and draw them on a bing map, so i need to iterate through the items.
I couldn't find any references online. So any help guys?

If you haven't seen this, this topic describes the high-level scorecard architecture -- http://msdn.microsoft.com/en-us/library/ee557351.aspx
Not sure if this will help with what you are trying to do, but this is a sample of looping through a scorecard object that is used by scorecard transforms: (http://msdn.microsoft.com/en-us/library/bb833673.aspx)
// Get the headers under the root row header.
List<GridHeaderItem> nonLeafRowHeaders = viewData.RootRowHeader.GetAllHeadersInTree();
// Get the leaf headers under the root column header.
List<GridHeaderItem> leafColumnHeaders = viewData.RootColumnHeader.GetAllLeafHeadersInTree();
foreach (GridHeaderItem rowHeader in nonLeafRowHeaders)
{
foreach (GridHeaderItem columnHeader in leafColumnHeaders)
{
// Get scorecard cells.
GridCell cell = viewData.Cells[rowHeader, columnHeader];
if (cell.IsCellEmpty || string.IsNullOrEmpty(cell.ActualValue.ToString()))
{
//do something with cell
}
viewData.Cells[rowHeader, columnHeader] = cell;
}
}

Related

Select UI Element by filtering properties in coded ui

I have a web application. And I am using coded ui to write automated tests to test the application.
I have a dropdown with a text box. Which on entering values in the textbox, the values in the dropdown gets filtered based on the text entered.
If I type inside textbox like 'Admin', I will get below options like this:
And I need to capture the two options displayed.
But using IE Developer tool (F12), I am not able to capture the filtered options, because the options that are displayed do not have any unique property (like this below). And the options that are NOT displayed have a class="hidden" property
Any way to capture the elements that are displayed by applying some kind of filter like 'Select ui elements whose class != hidden'
Thanks in advance!!
HI please try below code will it works for you or not.By traversing all those controls that have class ="hidden"
WpfWindow mainWindow = new WpfWindow();
mainWindow.SearchProperties.Add(HtmlControl.PropertyNames.ClassName, "hidden");
UITestControlCollection collection = mainWindow.FindMatchingControls();
foreach (UITestControl links in collection)
{
HtmlHyperlink mylink = (HtmlHyperlink)links;
Console.WriteLine(mylink.InnerText);
}
I'm not sure there is a way to do it by search properties, but there are other approaches.
One way would be to brute force difference the collections. Find all the list items, then find the hidden ones and do a difference.
HtmlControl listControl = /* find the UL somehow */
HtmlControl listItemsSearch = new HtmlControl(listControl);
listItemsSearch.SearchProperties.Add(HtmlControl.PropertyNames.TagName, "li");
HtmlControl hiddenListItemsSearch = new HtmlControl(listControl);
hiddenListItemsSearch.SearchProperties.Add(HtmlControl.PropertyNames.TagName, "li");
hiddenListItemsSearch.SearchProperties.Add(HtmlControl.PropertyNames.ClassName, "hidden");
var listItems = listItemsSearch.FindMatchingControls().Except(hiddenListItemsSearch.FindMatchingControls());
You will only be able to iterate this collection one time so if you need to iterate multiple times, create a function that returns this search.
var listItemsFunc = () => listItemsSearch.FindMatchingControls().Except(hiddenListItemsSearch.FindMatchingControls());
foreach(var listItem in listItemsFunc()){
// iterate 1
}
foreach(var listItem in listItemsFunc()){
// iterate 2
}
The other way I would consider doing it would be to filter based on the controls which have a clickable point and take up space on the screen (ie, not hidden).
listItemsSearch.FindMatchingControls().Where(x => {
try { x.GetClickablePoint(); return x.Width > 0 && x.Height > 0; } catch { return false; }
});

Highlight Duplicate list item in SharePoint 2013

I have a SharePoint 2013 (The Cloud version) custom list where 1 column is a text field where contact numbers are keyed in.
How can I get SharePoint to highlight duplicate values in that column so that every time a new item is added to the list, I'll know if the contact number has been used previously?
Ideally, here's what I'd get if I were to enter 816's details for the 2nd time:
CNO....Name.......Issue
816.....Blink........Login Problem (highlighted in red)
907.....Sink.........Access Denied
204.....Mink.........Flickering Screen
816.....Blink........Blank Screen (highlighted in red)
I've been struggling with this for awhile and would be very grateful for any advice. Thanks!
Since SharePoint 2013 uses Client Side Rendering (CSR) as a default rendering mode I would recommend the following approach. Basically the idea is to customize List View on the client side as demonstrated below.
Assume the Requests list that contains RequestNo column.
The following JavaScript template is intended for highlighting the rows when list item with RequestNo column occurs more then once:
SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
OnPostRender: function(ctx) {
var rows = ctx.ListData.Row;
var counts = getItemCount(rows,'RequestNo'); //get items count
for (var i=0;i<rows.length;i++)
{
var count = counts[rows[i]["RequestNo"]];
if (count > 1)
{
var rowElementId = GenerateIIDForListItem(ctx, rows[i]);
var tr = document.getElementById(rowElementId);
tr.style.backgroundColor = "#ada";
}
}
}
});
function getItemCount(items,propertyName)
{
var result = {};
for(var i = 0; i< items.length; i++) {
var groupKey = items[i][propertyName];
result[groupKey] = result[groupKey] ? result[groupKey] + 1 : 1;
}
return result;
}
How to apply the changes
Option 1:
Below is demonstrated probably one of easiest way how to apply those changes:
Open the page in Edit mode
Add Content Editor or Script Editor web part on the page
Insert the specified JavaScript template by enclosing it using
script tag into web part
Option 2:
Save the specified JavaScript template as a file (let's name it duplicatehighlight.js) and upload it into Site Assets library
Open the page in Edit mode and find JSLink property in List View web part
Specify the value: ~sitecollection/SiteAssets/duplicatehighlight.js and save the changes.
Result
SharePoint has some basic conditional formatting for Data View Web Parts and XSLT List Views, but the conditions you can use are rather limited. You can compare a field in the current item with a value that you specify. There are no formulas to count the number of items with the same name or similar, which would be the approach to use to identify duplicates.
If you need to identify duplicates, you may want to create a view that groups by the CNO number. Grouping will also include an item count, so you can run down the list and spot groups with more than one item.

How do you determine which row was selected in a Infragistics WebHierarchicalDataGrid when you have a Master Detail table configuration

I have a master table and two child detail tables under the master. When the user selects one of the detail tables the RowSelection event fires. I need to determine which table was selected. If the users selectes the second detail table then I need to obtain the data from a specific field. What code can be put in place to make this determination. Here is the code I have so far to grab the data, I just need to build the IF statment around this code.
String UploadIndex;
if (e.CurrentSelectedRows.Count > 0)
{
GridRecord oRow = e.CurrentSelectedRows[0];
UploadIndex = oRow.Items[0].Value.ToString();
}
Tried this but got controlmain is inaccessible due to its protection level.
ContainerGrid oRowIsland = WebHierarchicalDataGrid1.GridView.Rows[e.CurrentSelectedRows[0].Index].RowIslands[0];
if (oRow.Owner.ControlMain.ID == '2')
{
UploadIndex = oRow.Items[0].Value.ToString();
}
Use ContainerGridRecord type instead of GridRecord when declaring oRow, this way you will have access to oRow.Owner.ControlMain which is the grid that holds the row. In debug determine ID of the grid you're interested in and then you can do
If (oRow.Owner.ControlMain.ID == '...ID of second grid') {
// profit
}
Or use some other easily identifiable property of ControlMain grid that in your case assocciate with the second details.

SharePoint 2010 - Need suggestion

I have one datasheet like mentioned below
WorkWeek Person1 Person2
WW1 X Y
WW2 Z A
WW3 X Z
Where A,X,Y & Z are members of the sharepoint group.
Required I want display a webpart like this
WW1
Image1 Image2
X Y
Next Week the webpart should get updated like this dynamically.
WW2
Image3 Image4
Z A
Where this requirement is possible, If possible then pls suggest how to accomplish this.
I can provide you some Logic which may help you to accomplish this requirement.
Create one Visual web part with the user control which has html as per your requirement,
To get the data from the datasheet use the Code to read the data from Data sheet
When you want to display the data for the First week create one varible and maintain it to identify the sequence of week to get from datasheet.
First time When you access the datasheet set this varibale with your week of year number.
Condition the reading of datasheet with this variable like IF variable is null then assign it the week no of year.,
Check this variable next time you come to this logic that If variable is less than the week no current week no of year then take datasheet last you get + 1 means Datasheet 2 and so on
..
Sorry for bad english
variable : one for DaasheetNo, WeekNo,CurrentWeekNo
assign datasheetNo = Sheet1
If(WeekNo== Null)
{
first time getdata from DaasheetNo (First Sheet)
}
else if(WeekNo < CurrentWeekNo)
{
Get data from datasheetNo +1
}
Hope it helps you
This is called weekly update Webpart in SharePoint.
My Idea:
you can set one CurrentDate value like DateTime.Today to Current Web properties.also set one more properties which WorkWeek users. now check
SPWeb web = SPContext.Current.Web;
if (string.isnullorEmpty(web.Properties["CurrentDate"]))
{
web.Properties["CurrentDate"] = DateTime.Today.Tostring();
// do the stuff for displying data.
}
else
{
if(IFChangeNeeded())
{
// do the stuff for displying data.
}
else
{
web.Properties["CurrentDate"] = DateTime.Today.Tostring();
// do the stuff for displying data.
}
}
IfChangeNeeded() is function which return bool value. this function check that employee need to change on this week.
public bool IFChangeNeeded()
{
DateTime PropDate = Convert.ToDateTime(web.Properties["CurrentDate"]);
DateTime TDate = DateTime.Today;
if(WeekNo(TDate) == WeekNo(PropDate)) // WeekNo is function return weekno from current date.
{
return true;
}
else
{
return false;
}
}

Grails: How do I create filter like the ones in MS Excel?

I want to sort the elements in my list and have the option of filter them the same way MS Excel does.
So it should be able to keep the filtered elements in the table and apply a filter within those results as well. Also be able to sort them without refreshing the whole table.
Any help is greatly appreciated!
you can do it with a criteria in you list action of your controller
def result
if ( params?.filter && params?.filterVal) {
result = Book.createCriteria().list(max: params?.max, offset: params?.offset) {
eq(params?.filter,params?.filterVal)
}
} else {
// normal list retrieval code
}
where params?.filter is the property to filter on and params?.filterVal is the value

Resources