Loading ...
Sorry, an error occurred while loading the content.

Re: [ydn-javascript] Unable to set Focus on My Custom Collumn of the DataTable

Expand Messages
  • Satyam
    Why do you bother to update the row for every keystroke? After all, the input box is being updated by the user, you don t need to refresh it. What you can do
    Message 1 of 2 , Sep 3, 2008
    • 0 Attachment
      Why do you bother to update the row for every keystroke? After all, the
      input box is being updated by the user, you don't need to refresh it.
      What you can do is to update the value on the recordset by using
      Record.setData and leave the UI alone. Method updateRow will refresh
      the whole row and take the focus out of the input box, fixing that would
      be harder, if not impossible, than leaving it alone.

      Satyam


      myworld100us wrote:
      > The users of my app did not want to click on the OK/Cancel button
      > every time the update a column,So i created a custom Col for each Cell
      > in the datatable. The Problem is since I have to manually call the
      > updateRow of the datatable , I am not able to set the focus back on
      > the Cell . So what happens after each char whihc is typed in the input
      > box , the foucs
      > is lost and user has to again click on the input box to continue .
      > This is a big pain .
      > Here is my Code
      >
      > var myColumnDefs = [
      > {key:"delSelect", label:"Select",
      > formatter:YAHOO.widget.DataTable.formatCheckbox},
      > { key:"uomCd",
      > label:"CD" , formatter: function (el, oRecord,
      > oColumn, oData) {
      > var iden = oRecord.getId() + "uomCd";
      > var addSelect = oRecord.getData("addSelect");
      > if(addSelect=='1')
      > {
      > el.innerHTML = '<input size="25" style="font-size:
      > 15px;" id="'+iden+'" value="' + oData + '" onkeyup=updateCd(this.id)
      > /> ';
      >
      > }},
      >
      > //Notice the function updateCd.
      >
      > Here is the Actual function function of the same
      >
      >
      > function updateCd(colname)
      > {
      >
      > var newVal = document.getElementById(colname).value;
      > newVal = newVal.toUpperCase();
      > var col = colname.split("Cd");
      > var rec0 = myUMDataTable.getRecord(col[0]);
      > var row = myUMDataTable.getTrEl(rec0);
      > var recIndex = myUMDataTable.getRecordIndex(row);
      > var colUomDesc = col[0]+"uomDesc";
      > var uomDesc = document.getElementById(colUomDesc).value;
      > var data = rec0.getData();
      > data['updSelect']='true';
      > data['uomDesc']= uomDesc;
      > data['Cd']= newVal;
      > myUMDataTable.updateRow(recIndex,data);
      > document.getElementById(colname).focus();//This line does not set the
      > focus on the Cell . Sometime if I put some alerts I notice it sets the
      > focus before the char i typed , i dont know whats the relation between
      > alerts and the foucs
      > So if i type A---then the input box appers like this <Focus>A
      > instead of A<focus>
      > }
      >
      > Can anyone explain whats happening here ?
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      > ------------------------------------
      >
      > Yahoo! Groups Links
      >
      >
      >
      > ------------------------------------------------------------------------
      >
      >
      > No virus found in this incoming message.
      > Checked by AVG - http://www.avg.com
      > Version: 8.0.169 / Virus Database: 270.6.14/1647 - Release Date: 02/09/2008 6:02
      >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.