javascript - Set dojox.grid.datagrid header column width dynamically -


  • i have declarative dojox.grid.datagrid initial header column width. , have textbox. need is
  • in ui, if user enters value textbox, value should set dynamic width of column's header.

    <div class="claro" id="dfgdfgd" name="datagrid" onclick="setwidgetproperty(this.id,'xy','inner__dfgdfgd');" ondblclick="editcustomgrid(this.id)" onmouseup="setdocstyle(this.id)" style="height:200px; left:42px; position:absolute; top:89px; width:950px;">  <table class="claro" dojotype="dojox.grid.datagrid" id="inner__dfgdfgd" rowselector="10px" style="height: 180px; width: 300px;">       <thead>            <tr>                 <th field="column1" id="column1" noresize="true" width="100px">                      <label id="column1" onclick="getcustomgridcolname(this.id,'inner__dfgdfgd');" style="cursor:pointer; font-family: times; font-size:12pt;">                           column1                      </label>                 </th>                 <th field="column2" id="column2" noresize="true" width="100px">                      <label id="column2" onclick="getcustomgridcolname(this.id,'inner__dfgdfgd');" style="cursor:pointer; font-family: times; font-size:12pt;">                           column2                      </label>                 </th>            </tr>       </thead>  </table>  <input id="hidden__dfgdfgd" name="datagrid" style="display:none;" type="hidden"> 

i able particular column's width using below code. how set width textbox value.

dojo.foreach(dijit.byid(tableid).layout.cells, function(cell,idx){                 if(cell.field == id){                     headerwidth = cell.width;                     alert(headerwidth);                 }             }); 

there method called setcellwidth() (you can read in api documentation) can use change width of cells.

the step need complete update column (so changes become visible). step can completed cell.view.update();.

be aware: updating complete grid grid.update() or grid.sizechange() not enough because update column headers. (that's noticed.)

so in foreach loop like:

grid.setcellwidth(idx, "200px"); cell.view.update(); 

i made working jsfiddle can view here.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -