Announcement

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

    dropdowns in editable tables

    Build: SmartClient Version: v8.2p_2012-06-06/PowerEdition Development Only (built 2012-06-06)
    Browser: Any

    Many of our listgrids contain dynamic value maps which we have been able to set by using getEditorValueMap. But now we have a problem where when the listgrid is in normal state (not in edit mode), the key is shown, not the description which resides in the valueMap. But we have noticed that no matter what value we send over to the browser, the value always shows as a separate property. Basically what we want is the following:

    1. When the user double clicks on the row to show the editor and click on the dropdown icon, the value that is set on that field
    will be highlighted and not show as a separate value in the list.

    Run the testcase:
    In the first row click, it works fine because the value is the same as the first in the list. But now click on the third row and click on the dropdown icon, you'll notice that the highlighted value is not what the actual value is. Now if you change sRef_SF in the data to have the value as "360011764VK" instead of "360011764", looks fine visually but soon as I click to go into edit mode, there are two dropdown values - one being my value and the other coming from the valueMap.

    2. When the listgrid is in normal state, it should show the description instead of the key. - This is obvious as soon as you open the sample testcase.


    Please let me know how to fix this. It's become a pretty big issue on our side.

    Code:
    <HTML><HEAD><TITLE>Hover Issue</TITLE>
    
        
    </HEAD>
    <body class="pageBackground" marginwidth="0" marginheight="0" topmargin="0" leftmargin="0" scroll="no" style="overflow:hidden">
    
    
    
    
    <SCRIPT>var isomorphicDir = "isomorphic/"</SCRIPT>
        <SCRIPT>var isomorphicDir = "isomorphic/"</SCRIPT>
        <SCRIPT SRC=isomorphic/system/modules/ISC_Core.js></SCRIPT>
        <SCRIPT SRC=isomorphic/system/modules/ISC_Foundation.js></SCRIPT>
        <SCRIPT SRC=isomorphic/system/modules/ISC_Containers.js></SCRIPT>
        <SCRIPT SRC=isomorphic/system/modules/ISC_Grids.js></SCRIPT>
        <SCRIPT SRC=isomorphic/system/modules/ISC_Forms.js></SCRIPT>
        <SCRIPT SRC=isomorphic/system/modules/ISC_DataBinding.js></SCRIPT>
    	<SCRIPT SRC=isomorphic/skins/Enterprise/load_skin.js></SCRIPT>
    
    <SCRIPT>
    isc.screenReader = true;
    countryData = [
                {
                    cwPK__:"360011778", 
                    $isCwSelected:false, 
                    sRef_SF:"360011764", 
                    sRef_SF$L:{
                        "360011764":"360011764VK", 
                        "360011765":"360011765VK", 
                        "360011766":"360011766VK", 
                        "360011767":"360011767VK", 
                        "360011768":"360011768VK", 
                        "360011769":"360011769VK", 
                        "360011770":"360011770VK", 
                        "360011771":"360011771VK", 
                        "360011772":"360011772VK", 
                        "360011773":"360011773VK", 
                        "360011774":"360011774VK", 
                        "360011775":"360011775VK", 
                        "360011776":"360011776VK", 
                        "360011777":"360011777VK"
                    }, 
                    sRef_SF$k:""
                }, 
                {
                    cwPK__:"360011780", 
                    $isCwSelected:false, 
                    sRef_SF:"360011764"
                }, 
                {
                    cwPK__:"360011782", 
                    $isCwSelected:false, 
                    sRef_SF:"360011766"
                }, 
                {
                    cwPK__:"360011784", 
                    $isCwSelected:false, 
                    sRef_SF:"360011768"
                }, 
                {
                    cwPK__:"360011786", 
                    $isCwSelected:false, 
                    sRef_SF:"360011770"
                }
            ];
    
    
    
    isc.ListGrid.create({
        ID: "countryList",autoDraw:true,
        width:500, height:500, alternateRecordStyles:true,
        data: countryData,canEdit:true,
    	getEditorValueMap: function(field, values){
        var val = null;
        var valueMapName = field.name + "$L";
        if(values!=null){
          var cwValues = this.getRecord(0);
          if (cwValues != null) {
            val = cwValues[valueMapName];
            if (val != null) {
              // Store the value map into cwValueMaps property and
              // remove the map from the record so it won't be serialized 
              // back to the server when performing "UPDATE" request.
              if (this.cwValueMaps == null)
                this.cwValueMaps = {};
              this.cwValueMaps[valueMapName] = val;
              cwValues[valueMapName] = null;
            }
          }
          if (val == null && this.cwValueMaps != null) {
            val = this.cwValueMaps[valueMapName];
          }
          return val;
        }
        
      },
        fields:[
            {name:"sRef_SF", title:"sRef_SF", width:50, type:"select"}
        ]
    })
    
    </script>
    </BODY>
    </html>
    Last edited by acarur01; 4 Jul 2012, 11:06.

    #2
    The editorValueMap has no impact on normal display. You need to use formatCellValue or field.displayField to influence how a value appears when you are not editing. So in this case, you could add a formatCellValue function that accesses the same valueMap you are currently using from getEditorValueMap().

    Comment


      #3
      Ok. I've tried implementing your suggestion. At first it looks like it works but as soon as I edit the value it goes back to displaying the key. For some reason formatCellValue gets called with a record that does not have the valueMap


      1. Run the testcase.
      2. Double click on the first row and change the value.
      3. Now double click on another row. You'll notice that the first row no longer shows the description.

      I've debugged formatCellValue - it is being called once the editor exits? and the following lines of code fail
      Code:
      				var valueMapName = field.name + "$L";
      				var cwValues = grid.getRecord(0);
      				if (cwValues != null) {
      				  val = cwValues[valueMapName];
      				  if(val!=null){
      					return val[value];
      Please let me know what I am missing/doing wrong.

      Code:
      <HTML><HEAD><TITLE>Hover Issue</TITLE>
      
          
      </HEAD>
      <body class="pageBackground" marginwidth="0" marginheight="0" topmargin="0" leftmargin="0" scroll="no" style="overflow:hidden">
      
      
      
      
      <SCRIPT>var isomorphicDir = "isomorphic/"</SCRIPT>
          <SCRIPT>var isomorphicDir = "isomorphic/"</SCRIPT>
          <SCRIPT SRC=isomorphic/system/modules/ISC_Core.js></SCRIPT>
          <SCRIPT SRC=isomorphic/system/modules/ISC_Foundation.js></SCRIPT>
          <SCRIPT SRC=isomorphic/system/modules/ISC_Containers.js></SCRIPT>
          <SCRIPT SRC=isomorphic/system/modules/ISC_Grids.js></SCRIPT>
          <SCRIPT SRC=isomorphic/system/modules/ISC_Forms.js></SCRIPT>
          <SCRIPT SRC=isomorphic/system/modules/ISC_DataBinding.js></SCRIPT>
      	<SCRIPT SRC=isomorphic/skins/Enterprise/load_skin.js></SCRIPT>
      
      <SCRIPT>
      isc.screenReader = true;
      countryData = [
                  {
                      cwPK__:"360011778", 
                      $isCwSelected:false, 
                      sRef_SF:"360011764", 
                      sRef_SF$L:{
                          "360011764":"360011764VK", 
                          "360011765":"360011765VK", 
                          "360011766":"360011766VK", 
                          "360011767":"360011767VK", 
                          "360011768":"360011768VK", 
                          "360011769":"360011769VK", 
                          "360011770":"360011770VK", 
                          "360011771":"360011771VK", 
                          "360011772":"360011772VK", 
                          "360011773":"360011773VK", 
                          "360011774":"360011774VK", 
                          "360011775":"360011775VK", 
                          "360011776":"360011776VK", 
                          "360011777":"360011777VK"
                      }, 
                      sRef_SF$k:""
                  }, 
                  {
                      cwPK__:"360011780", 
                      $isCwSelected:false, 
                      sRef_SF:"360011764"
                  }, 
                  {
                      cwPK__:"360011782", 
                      $isCwSelected:false, 
                      sRef_SF:"360011766"
                  }, 
                  {
                      cwPK__:"360011784", 
                      $isCwSelected:false, 
                      sRef_SF:"360011768"
                  }, 
                  {
                      cwPK__:"360011786", 
                      $isCwSelected:false, 
                      sRef_SF:"360011770"
                  }
              ];
      
      
      
      isc.ListGrid.create({
          ID: "countryList",autoDraw:true,
          width:500, height:500, alternateRecordStyles:true,
          data: countryData,canEdit:true,
      	getEditorValueMap: function(field, values){
          var val = null;
          var valueMapName = field.name + "$L";
          if(values!=null){
            var cwValues = this.getRecord(0);
            if (cwValues != null) {
              val = cwValues[valueMapName];
              if (val != null) {
                // Store the value map into cwValueMaps property and
                // remove the map from the record so it won't be serialized 
                // back to the server when performing "UPDATE" request.
                if (this.cwValueMaps == null)
                  this.cwValueMaps = {};
                this.cwValueMaps[valueMapName] = val;
                cwValues[valueMapName] = null;
              }
            }
            if (val == null && this.cwValueMaps != null) {
              val = this.cwValueMaps[valueMapName];
            }
            return val;
          }
          
        },
          fields:[
              {name:"sRef_SF", title:"sRef_SF", width:50, type:"select",editorType: "SelectItem",
      			formatCellValue:function(value, record, rowNum, colNum, grid){
      				var field = grid.getField(colNum);
      			  if(field.editorType == "SelectItem"){
      				var valueMapName = field.name + "$L";
      				var cwValues = grid.getRecord(0);
      				if (cwValues != null) {
      				  val = cwValues[valueMapName];
      				  if(val!=null){
      					return val[value];
      				  }else{ 
      				   return value;
      				  }
      				}
      			}
      			}
      		}
          ]
      })
      
      </script>
      </BODY>
      </html>

      Comment


        #4
        Your getEditorValueMap function has a line that wipes out the valueMap.

        Comment


          #5
          well fml. Thanks.

          Comment

          Working...
          X