Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
225
Problems while setting ValueList from javascript code
posted

I have a WebGrid where there is a first column of Type DropDownList , and another DropDownList column .

The first column has the datasource settings in the Page_Load (for all the rows the first column has the same values as ValueList), instead the secound column should have a ValueList that depends from the currently selected values in the first column.

This is the aspx part for the columns:

<igtbl:UltraGridColumn Key="Type" IsBound="true" BaseColumnName="Type" AllowUpdate="Yes" Type="DropDownList" Width="400px">
   <Header Caption="Type">
      <RowLayoutColumnInfo OriginX="1"></RowLayoutColumnInfo>
   </Header>
   <Footer>
      <RowLayoutColumnInfo OriginX="1"></RowLayoutColumnInfo>
   </Footer>              
</igtbl:UltraGridColumn>      
                                                                      
<igtbl:UltraGridColumn Key="StentDiam" IsBound="true" BaseColumnName="StentDiam" Width="70px" Type="DropDownList">
   <Header Caption="Diam.">
      <RowLayoutColumnInfo OriginX="2"></RowLayoutColumnInfo>
   </Header>
   <Footer>
      <RowLayoutColumnInfo OriginX="2"></RowLayoutColumnInfo>
   </Footer>
   <ValueList></ValueList>
</igtbl:UltraGridColumn>

 And:

<ClientSideEvents CellChangeHandler="grdStentsLAD_CellChangeHandler"/>

The javascript code:

function grdStentsLAD_CellChangeHandler(gridId, newActiveCellId) {
   if (newActiveCellId == "") {
      // when click on Add New button
      return;
   }
   var objGrid = igtbl_getGridById(gridId);
   var objCell = igtbl_getCellById(newActiveCellId);
   var objRow = objCell.getRow();
   if (objGrid.Rows.getRow(objRow.getIndex()).getCellFromKey('StentDiam').Id == newActiveCellId) {
      var strType = objGrid.Rows.getRow(objRow.getIndex()).getCellFromKey('Type').getValue();
      PageMethods.GetFilteredDiams(strType, newActiveCellId, grdStentsLAD_CellChangeHandler_Callback, grdStents_CellChangeHandler_ErrorCallback, gridId);
   }
}

In my js code i'm calling a Ajax page method (GetFilteredDiams), that returns an array of strings , so the callback code is

function grdStentsLAD_CellChangeHandler_Callback(result, response, context) {
   var strCellId = result[0];
   // response contains gridId passed as context
   var objGrid = igtbl_getGridById(response);
   var objCell = igtbl_getCellById(strCellId);
   var objRow = objCell.getRow();
   var objColumnDiam = igtbl_getColumnById(strCellId);
   var vlist = new Array(result.length - 1);
   for (i = 1; i < result.length; i++) {
      vlist[i] = new Array(result[i], result[i]);
   }
   objColumnDiam.ValueList = vlist;
}

The first array element is used to save the HTMLid of the original cell (CellId).

Following the code with debugger i can see that all is working as expected, the returned array from the page method contains the right values that i'm expected to see for the clicked StentDiam cell, but there is a problem: opening the list with the cell dropdown button doesn't immediately show the right values (i can see the values of another row previously clicked, for example) even if in js code the values was correct: i must click on another cell (for example the Type) then reclicking the StentDiam cell the ValueList is now correct (i hope that my explanation is clear...)

Why this problem? could be that with the service pack , downloadable only if you have a regular license, is resolved? or there is some code to add?

There is even the fact that the ValueList for StentDiam should change changing the selected Type, but for now i'm interested to resolve this issue.

I'm using Visual Studio 2008 with the latest Infragistics trial :i'm evaluating just for the problem of dinamically filtered DropDown that with a GridView ,working with postbacks, is very slow.