Xpages "filters by category name" with two field values ​​(restricting view to multiple categories)

I want to create a view that only displays the projects of the selected customers and services, so I created a view that categorizes the customer and service columns and a view pane for that view. If I supply document1.getDocument (). getItemValueString ("Client")

works with a limited category. How can I do this with dragging category columns.

Thank you in advance

+3


source to share


3 answers


Can you implement repetition during repetition for this?



The first repeat will capture your first category. Then inside you have a panel and a repeat, and the second repeat will further filter the data source by the second category

0


source


You are cheating. Specify one column that brings together client and project. Take this column in your selection and split it into code.

Then use the selected value for one column. Let's assume your source columns are client and project. This way your new column will have a formula customer+"~"+project

. Then you read these values ​​to populate the SSJS object or variable so you can get clients (first dropdown) and projects (second dropdown). In the dropdown you can use the format Display|Value

, so a good approach is to have the value in the client project ~.

As said, you can do it in Java or JavaScript. Since I really like the structure of the Java collection, here's the Java version:

import java.util.Set;
import java.util.Map;
import java.util.TreeMap;
import java.util.TreeSet;

import lotus.domino.Database;
import lotus.domino.NotesException;
import lotus.domino.View;
import lotus.domino.ViewEntry;
import lotus.domino.ViewEntryCollection;

public class SplitCategoryBean {

    private static final String SEPARATOR = "~";
    private final Map<String,Set<String>> allCategories = new TreeMap<String, Set<String>>();

    public void populate(Database db, String viewName) throws NotesException {
        View v = db.getView(viewName);
        ViewEntryCollection vec = v.getAllEntries();
        ViewEntry ve = vec.getFirstEntry();

        while (ve != null) {
            ViewEntry nextVE = vec.getNextEntry(ve);         
            this.addEntry(ve.getColumnValues().get(0).toString());
            ve.recycle();
            ve = nextVE;
        }

        vec.recycle();
        v.recycle();
    }

    private void addEntry(String combinedCategory) {
        String[] splitCategory = combinedCategory.split(SEPARATOR);
        String key = splitCategory[0];
        String value = splitCategory[1];
        Set<String> thisCategory = (this.allCategories.containsKey(key)) ? this.allCategories.get(key): new TreeSet<String>();
        thisCategory.add(value+"|"+combinedCategory);
        this.allCategories.put(key, thisCategory);       
    }

    public Set<String> getFirstCategory() {
        return this.allCategories.keySet();
    }

    public Set<String> getSecondCategoryReadyForDropDown(String key) {
        return this.allCategories.get(key);
    }

}

      



You would set this up as a managed bean (viewScope) and in queryOpen you call the fill method. Then you can easily bind your first selection to #{beanName.firstCategory}

for selection and for example #{viewScope.curCustomer}

for value. The second dropdown is you are using rendered="#{viewScope.curCustomer}"

, so it only shows when you select a client. And you bind the selection to#{javascript:beanName.getSecondCategoryReadyForDropDown(viewScope.curCustomer);

Place updates on change events and render the view only if a project is selected.

Does this work for you?

0


source


Thanks guys,

I created a view where the first column is classified and its value is Customer + Service and then it puts

document1.getDocument (). getItemValueString ("Client") + document1.getDocument (). getItemValueString ("Service")

in the "filter by category name" field of the viewer now works.

0


source







All Articles