DataLink and other Scripts

Generic selectors
Exact matches only
Search title only
Search in content
Search in all posts
Search in pages
Answers
Questions
Solved2.67K viewsScripting
0

Can someone help me with the scripts for the following actions:

1. Run Datalink for a specific matrix using button controlled script
2. Script to delete all items of a category except the first
3. How to limit the number of items in a category to a certain number such as 100. That is when user presses enter, new items are created up to the limit set.
4. How to control the cursor to move to the right after pressing enter in a cell. By default the cursor moves to down but i know in Excel there is a setting to control its movement. How can this be done in Quantrix.
5. How to delete all empty rows or columns in a matrix with a script.

Thanks in advance

Selected answer as best
0

tawanda,

This is how you would delete the blank rows assuming that Category A of Matrix2 is in the Row position.
//DeleteNonBlankRecordInCategory
//By rlopez 10/15/2014

//Begin the For Each Loop
|Matrix2::A|.items.each
{
//String[] x = it.values
//System.out.println(x)
//Setup the Array
String[] arr = it.values
//Set Counter
counter =0
//Step through each element of the Array and evaluate if Null. If null then increase the counter.
for (int i = 0; i< arr.length; i ++)
if(arr[i]!=null)
counter++
//Where only null values where found in the arr of it.values delete that item
if(counter==0)
it.delete()
}

Selected answer as best
0

Thank you so much but this deletes all rows both empty and non-empty. How can I refine this to delete only empty rows?

0

tawanda,

Somewhat of an answer to #2.

If the first item of the category is not volitle then the following code should work:

[color=#0000FF:2i88ndi1]Set KeepItem = [|Matrix1::FirstItem|]
|Matrix1::B|.items.each

{
if(!KeepItem.contains(it))
it.delete()
}[/color:2i88ndi1]

Note this is code using simple A & B category tiles and the first item in CategoryB is called "FirstItem"

0

Hi RLopez, thank you very much for your response:

1. Thanks, I will use this.
2. No, I do not intend to hide empty rows but to delete them. I know how to hide them but I need a script that checks in a matrix and deletes all empty rows.

I look forward to more help for number 2 above plus the rest of the questions.

Thanks once again.

0

Answer to
1. Run Datalink for a specific matrix using button controlled script
|YourMatrixNameHere|.updateDataLink()

5. How to delete all empty rows or columns in a matrix with a script.
Have you considered using View –> Hide Empty option.

Latest Questions