title: How to change a specific RowData value in a jqGrid?
body: <p>
          
          
              
              
              
              
              
                  
                      
                  
              <br>
              
          
          
          
          
          
      </p>
  
  <p>And the script used is</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
          var lastSelection;
          var idCategoria;
          var nomeCategoria;
  
          function editRow(id) {
              if (id &amp;&amp; id !== lastSelection) {
                  var grid = jQuery("#&lt;%= JQGrid1.ClientID %&gt;");
  
                  if (document.getElementById(lastSelection + "_NomeCategoria") != null) {
                      if ( document.getElementById(lastSelection + "_NomeCategoria").value != undefined ) {
                          var objeto = document.getElementById(lastSelection + "_NomeCategoria");
                          idCategoria = objeto.value;
                          nomeCategoria = objeto[objeto.selectedIndex].text;
                      }
                  }
  
                  if (lastSelection != undefined) {
                      grid.updateGridRows("{IdCategoria:" + idCategoria + "}", lastSelection);
                      grid.saveRow(lastSelection, false);
                      //grid.setCell(lastSelection, "IdCategoria", idCategoria);
                      //grid.setRowData(lastSelection, "{IdCategoria:" + idCategoria + "}");
                  }
  
                  try
                  {
                      grid.restoreRow(lastSelection, defineCategoria);
                  }
                  catch(err)
                  {
                      alert(err.description);
                  }
                  grid.editRow(id, true, selecionaCategoria);
                  lastSelection = id;
              }
          }
  
          function selecionaCategoria(id) {
  
              var grid = jQuery("#&lt;%= JQGrid1.ClientID %&gt;");
              var linha = grid.getRowData(id);
              var idCategoria = linha.IdCategoria;
              var comboCategorias = document.getElementById(id + "_NomeCategoria");
              if (idCategoria != "" &amp;&amp; idCategoria != undefined) {
                  try {
                      for (var i = 0; i &lt; comboCategorias.childNodes.length; i++) {
                          if (comboCategorias.childNodes[i].value == idCategoria) {
                              comboCategorias.childNodes[i].selected = true;
                              break;
                          }
                      }
                  }
                  catch (err) {
                      alert(err.description);
                  }
              }
          }
  
          function defineCategoria(id) {
              var grid = jQuery("#&lt;%= JQGrid1.ClientID %&gt;");
              grid.setCell(id, "NomeCategoria", DefineUrlCategoria(idCategoria, nomeCategoria));
          }
  
          // The FormatFunction for CustomFormatter gets three parameters
          // cellValue - the original value of the cell
          // options - as set of options, e.g
          //   options.rowId - the primary key of the row
          //   options.colModel - colModel of the column
          // rowData - array of cell data for the row, so you can access other cells in the row if needed
  
          function DefineUrl(cellValue, options, rowObject) {
              var caminho = "";
              if (isArray(rowObject)) {
                  if (rowObject[1] != "" &amp;&amp; rowObject[1] != undefined) {
                      //var caminho = "&lt;a href='/Ferramenta/Graficos/GraficoCategoria.aspx?idCategoria=" + rowObject[1] + "'&gt;" + cellValue + "&lt;/a&gt;";
                      caminho = DefineUrlCategoria(rowObject[1], cellValue);
                  }
                  else {
                      caminho = cellValue;
                  }
              }
              else {
                  if (idCategoria != "0") {
                      caminho = DefineUrlCategoria(idCategoria, nomeCategoria);
                  }
                  else {
                      caminho = nomeCategoria;
                  }
              }
              return caminho;
          }
  
          function isArray(o) {
              return (typeof (o.length) == "undefined") ? false : true;
          }
  
  
          function DefineUrlCategoria(idCategoria, nomeCategoria) {
              var caminho = "&lt;a href='/Ferramenta/Graficos/GraficoCategoria.aspx?idCategoria=" + idCategoria + "'&gt;" + nomeCategoria + "&lt;/a&gt;";
  
              return caminho;
          }
      &lt;/script&gt;
  </code></pre>
  
  <p>When the rows are not in edit mode the fifth columns shows a link and while editing it shows a dropdown. To select the correct item in the dropdown I use the second column that has the ID that came from the database.</p>
  
  <p>The problem is that after changing the item and saving it to the database, this column value doesn't change. How can I do it after the grid.saveRow(lastSelection, false); ?</p>
  
  <p>Thanks.</p>