Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    FormItem equivalent for ListGridField.getEditorValueMap?

    In an editable grid, I can use a SelectItem that shows available options that are returned by getEditorValueMap(). I wonder how to do this in a DynamicForm.

    #2
    You can override SelectItem.getValueMap(), although if you could express the dynamic options as an optionDataSource with criteria, that would work in both contexts.

    Comment


      #3
      Good point, I'll think about that. I want to avoid a lot of server side communications for small option sets and have therefore generated Javascript arrays. Can I use such an array in a client-only data source that works just like a "normal" (with server round-trip) data source?

      Comment


        #4
        Yes, that's what clientOnly DataSources are for. Provide the Array as the "testData" property.

        Comment


          #5
          Please allow me to ask one more question for this particular case.

          My application is built for an enterprise and defines the different companies of the holding and their departments. Until now I defined JavaScript arrays with the companies and the IDs of the departments belonging to those companies. I've replaced these arrays with client-only data sources.

          Some people are authorized to edit data for all departments in a company, while others are only authorized for one (or a couple). The new client-only data sources make it easy to apply a company filter to get ALL departments for a company. But what for the second case? I need to compare the departments with a list of authorized departments. I could make a client-only data source for these authorizations but this list is too long. Therefore I only save their IDs and need to filter the departments data source. I guess there is no option to apply an array as filter?

          Any ideas on that? If my use case isn't clear, please let me know.

          Comment


            #6
            Don't really follow, but you can always implement your own filtering logic and your own interpretation of the criteria.

            Comment


              #7
              Let me clarify my earlier example. Given this dataSource:

              Code:
              var companiesDataSource = isc.DataSource.create({
                clientOnly: true,
                fields: [
                  {name: 'id', primaryKey: true, type: 'integer'},
                  {name: 'name', type: 'text'}
                ],
                testData: [
                  {id: 1, name: 'Company X'},
                  {id: 2, name: 'Company Y'},
                  {id: 3, name: 'Company Z'}
                ]
              });
              An user could have authorization for company 1 and 2 (not 3). Can I do this via filtering?

              Comment


                #8
                For everybody that wants to know the answer, I've just discovered it myself, so consider this question answered. :-)

                Yes it's possible, I've added this to the company_id field (I chose to do this in the data source itself):

                Code:
                getPickListFilterCriteria: function () {
                  return {
                    fieldName: 'id',
                    operator: 'inSet',
                    value: [1, 2]
                  };
                }
                For simplicity's sake, I've used hard values for the company id, but in my application I retrieve it from a function returning the authorized company IDs.

                Comment

                Working...
                X