Announcement

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

    Updating hidden fields in a list grid

    Hi,

    I have a ListGrid which is mapped to a DataSource xml. The DataSource xml has 5 fields defined and is further mapped to database columns in the back end. I am showing only the first two fields in my listgrid and use the other fields data also for some calculations.

    var record = listgridname.getRecord(0);
    var field3value = record.field3

    This is how i access the values of the unshown fields. Now I have a doubt on updating this value.

    Now i need to make a few calculations and update all the fields in the listgrid, even the fields which iam not showing.

    listgridname.setEditValue(0,field3,newValue);

    I am using the above to update the new value to the unshown field. Its working for the first two fields but not for the unshown fields. How can i update or set new value to those fields which i dont show?

    #2
    What is "field3" in your setEditValue() call? Valid params there are the colNum or field name (as a String).

    Comment


      #3
      field3 is the name of the field to which i am trying to set the new value. This feild is not included in the ListGrid field definition.

      simply saying we need to hide a column in the list grid ,we will set a values in the hidden column field . Problem i am facing is when i make the column hidden, iam not able to edit or set a new value to the field .

      Comment


        #4
        Hi,
        setEditValue() should work - having set the edit value you will of course need to actually save the value to the server as well.
        For example:

        - navigate to the 'editByRow' example in the SDK: http://localhost:8080/isomorphic/sys...html#editByRow
        - open the developer console ("javascript: isc.showConsole()" in the URL bar)
        - from the Eval area of the developer console modify the edit value for the "article" field for some record
        countryList.setEditValue(2, "article", "moo")
        - save the edited value - for example using the 'saveAllEdits' method
        countryList.saveAllEdits()

        Now look at the hidden field value for the record via countryList.data.get(2).

        You should see the value for the hidden 'article' field has been updated.

        Let us know if this doesn't answer your question.

        Thanks
        Isomorphic Software

        Comment


          #5
          ListGrid: Manipulating and saving columns that have been hidden.

          Version: SNAPSHOT_v9.1d_2014-01-27/PowerEdition Development Only (built 2014-01-27)

          Browser: Firefox 26.0

          Hello,

          I am trying to do something similar with a Listgrid with similar issues. I have a Listgrid that gives the user the option to show or hide columns. By default, some of the columns are already hidden when the grid is initialized, but the user is welcome to turn them on or off as needed. Most of these hidden fields are picklist controls.

          There are two issues I have.

          The first one is, if I change the value in one of the displayed columns, then hide to column, then save the record via the saveEdits or saveAllEdits function, that value that is hidden does not show up in the Console Log as being changed (values list) and does not make it to the database. This happens on all the columns I've changed a value in, then hidden the column.

          The other issue I have is just changing the hidden field. I can't manipulate it (setEditValue) unless I execute a showField on the column first. If I show the column, then hideField after setting the value, when I manually show the column on the grid, the value I set it to is no longer there.

          If I skip the hideField on the column, it all works fine.

          I suppose I can work around the issues by:

          Showing all the columns programatically before saving them, then hide them again after the fact. And I also suppose I can synchronize the "hidden" picklist fields via the show function on the field itself. But this is not as easy as I was hoping it would be.

          Any guidance would be welcome. Thanks.

          Paul Fincke

          Comment


            #6
            This isn't the normal behavior of the grid - see above for sample code and modifications to verify normal behavior if you'd like to. So we'd need some way to reproduce the issue you're seeing.

            Comment


              #7
              Originally posted by Isomorphic View Post
              This isn't the normal behavior of the grid - see above for sample code and modifications to verify normal behavior if you'd like to. So we'd need some way to reproduce the issue you're seeing.
              Sorry it's taken me so long to respond.

              I'm not going to worry about the grid update issue since toggling the show/hide on the columns was a pretty easy and effective workaround.

              But I may be doing something wrong in my list grid that utilizes picklists. So here is some code to demonstrate what I'm seeing:

              - If I edit the "Text" field, then hide the column, then show it again, the edited value displays. It works the same for the "Date" field.

              - If I change the "ComboBox" field, hide and show it, the value returns back to the original value and my changes are lost.

              Code:
              <script>
              	var dsPickList = isc.DataSource.create( {
              		name: "pickListValues",
              		clientOnly: true,
              		fields: [
              			{ name: "ID", type: "number", primaryKey: true },
              			{ name: "CODE", type: "text" },
              			{ name: "DESCRIPTION", type: "text" }
              		],
              		testData:  [
              			{ ID: 1, CODE: "A", DESCRIPTION: "First" },
              			{ ID: 2, CODE: "B", DESCRIPTION: "Second" },
              			{ ID: 3, CODE: "C", DESCRIPTION: "Thrid" },
              			{ ID: 4, CODE: "D", DESCRIPTION: "Fourth" },
              			{ ID: 5, CODE: "E", DESCRIPTION: "Fifth" },
              			{ ID: null, CODE: "", DESCRIPTION: "None of the Above" }
              		]
              	});
              
              	var grid = isc.ListGrid.create( {
              		canEdit: true,
              		editEvent: "click",
              		fields: [
              			{ name: "Text", type:"text", width: 150 },
              			{ name: "Date", type:"date" },
              			{ 
              				name: "ComboBox", 
              				editorType: "ComboBoxItem",
              				displayField: "CODE",
              				valueField: "ID",
              				displayValueFromRecord: true,
              				addUnknownValues: false,
              				width: 80,
              				editorProperties: { 
              					optionDataSource: dsPickList,
              					addUnknownValues: false,
              					completeOnTab: true,
              					displayField: "CODE",
              					pickListWidth: 250,
              					pickListProperties:{
              						autoFetchData: false,
              						fetchMissingValues: true,
              						canFilter: false,
              						showFilterEditor: true,
              						showAllRecords: false,
              						filterOnKeypress: true
              					},
              					pickListFields: [
              						{name:"CODE"},
              						{name:"DESCRIPTION"}
              					]
              				}	
              			}
              		],
              		data: [ 
              			{ Text: "Row 1", Date: "01/02/2003", ComboBox: 1 },
              			{ Text: "Item 2", Date: "12/11/2010", ComboBox: 2 },
              			{ Text: "Thing 3", Date: "05/05/2005", ComboBox: null }
              		]
              	});
              			
              	var vLayout = isc.VLayout.create( { 
              		width: 350,
              		members: [ grid ]
              	} );
              
              	vLayout.show();
              </script>

              Comment


                #8
                Your ComboBoxItem has addUnknownValues:false, so this means it will reject typed-in values that don't match something in the dataset.

                So most likely what you are seeing is that you type something in that doesn't match any records, then hide the field and the value is dropped. But the same thing would happen if you just focused in another field, and is the expected behavior of addUnknownValues:false.

                Comment


                  #9
                  Unfortunately that's not the case.

                  We select an entry from the drop-down grid. The value exists, is valid, displays in the grid.

                  If we save the changes in the grid without toggling the column visibility, the expected, valid, value is sent in the request.

                  Once we toggle the column however, the values are lost.

                  Comment


                    #10
                    We have run your test case and we're not seeing the behavior you describe.
                    Can you clarify three things:

                    Firstly - which build are you working with (full version as reported by evaluating isc.version)? If it's not the most recent nightly build from some branch - do you also see the problem with the most recent nightly build?

                    Secondly - Is this browser specific? Which browser/OS configuration are you testing with

                    Thirdly - steps to reproduce. We're doing the following

                    - Open the test case
                    - double click the "ComboBox" field to start editing
                    - select a value (say "C")
                    - hit "Enter" to save the edit and dismiss the editor
                    - right click on the header and use the "Columns..." submenu to hide the ComboBox field
                    - right click on the header and use the "Columns..." submenu to show the ComboBox field again

                    Does this match your steps to reproduce? If not, can you break down exactly what you are doing to see the problem?

                    Thanks
                    Isomorphic Software

                    Comment


                      #11
                      Screen shots

                      Okay. I walked through it a few more times and narrowed down the combination that I think is the problem:

                      1. Edit the row and click on the ComboBox field.
                      2. Type (don't select) a valid code in the ComboBox.
                      3. Click the column headers. The change in the ComboBox disappears.

                      If you select a ComboBox item instead of typing one and walk through the same steps, there is no problem.

                      Attached are the screen shots of my steps to reproduce.

                      Maybe I need to do something in the change or changed event to resolve this issue.
                      Attached Files

                      Comment


                        #12
                        We see the problem and have someone working on it. It's proving a little tricky to resolve, but we will follow up as soon as we have a solution for you

                        Regards
                        Isomorphic Software

                        Comment


                          #13
                          We've now made a change which will address this issue. This will be present in the 9.1d build dated Feb 11 or above.

                          One note on this: Your example field is defined like this:
                          Code:
                          			{ 
                          				name: "ComboBox", 
                          				editorType: "ComboBoxItem",
                          				displayField: "CODE",
                          				valueField: "ID",
                          				displayValueFromRecord: true,
                          				addUnknownValues: false,
                          				width: 80,
                          				editorProperties: { 
                          					optionDataSource: dsPickList,
                          					addUnknownValues: false,
                          					completeOnTab: true,
                          					displayField: "CODE",
                          					pickListWidth: 250,
                          					pickListProperties:{
                          						autoFetchData: false,
                          						fetchMissingValues: true,
                          						canFilter: false,
                          						showFilterEditor: true,
                          						showAllRecords: false,
                          						filterOnKeypress: true
                          					},
                          					pickListFields: [
                          						{name:"CODE"},
                          						{name:"DESCRIPTION"}
                          					]
                          				}	
                          			}
                          This appears slightly incorrect - you define a displayField and a valueField for the ListGrid column, but you don't define an optionDataSource.
                          As a result, it attempts to read the value of the displayField from the ListGrid record. This is why the column is initially empty even though there is a value for the ComboBox field for the first two records in the grid's data.
                          If you specify the optionDataSource for the ListGrid field as a whole, the displayField / valueField is used as a server side valueMap, using the optionDataSource's data as a set of key/values. This valueMap is applied to the "ComboBox" field value within the gri ddata, and you'll see the static data display the expected value:

                          Code:
                          			{ 
                          				name: "ComboBox", 
                          				editorType: "ComboBoxItem",
                          				displayField: "CODE",
                          				valueField: "ID",
                          				optionDataSource: dsPickList,
                          				displayValueFromRecord: true,
                          				width: 80,
                          				editorProperties: { 
                          					addUnknownValues: false,
                          					completeOnTab: true,
                          					pickListWidth: 250,
                          					pickListProperties:{
                          						autoFetchData: false,
                          						fetchMissingValues: true,
                          						canFilter: false,
                          						showFilterEditor: true,
                          						showAllRecords: false,
                          						filterOnKeypress: true
                          					},
                          					pickListFields: [
                          						{name:"CODE"},
                          						{name:"DESCRIPTION"}
                          					]
                          				}	
                          			}
                          Regards
                          Isomorphic Software

                          Comment


                            #14
                            Just a further note that listGridField.optionDataSource will load the entire dataset of the optionDataSource up front. In this little sample, you *need* to set it because of how you've arranged your sample data. In a real application, you would not usually do so.

                            See the docs for both listGridField.optionDataSource and dataSourceField.includeFrom to understand how to use displayField and optionDataSource efficiently.

                            Comment

                            Working...
                            X