cells.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*******************************************************************************
  2. * IBM Confidential
  3. *
  4. * OCO Source Materials
  5. *
  6. * A and PM: PD
  7. *
  8. * (c) Copyright IBM Corp. 2014
  9. *
  10. * The source code for this program is not published or otherwise divested of
  11. * its trade secrets, irrespective of what has been deposited with the U.S.
  12. * Copyright Office.
  13. ******************************************************************************/
  14. define([
  15. "dojo/_base/declare",
  16. "dojox/grid/DataGrid"
  17. ],function(declare){
  18. var PdSelect = declare("pd.widgets.grid.cells.Select", [dojox.grid.cells.Select], {
  19. // overwrite dojo original one
  20. formatEditing: function(inDatum, inRowIndex){
  21. this.needFormatNode(inDatum, inRowIndex);
  22. var h = [ '<select onchange="pd.connect.publish(\'/pd/widgets/grid/cells/applyChange\');" class="dojoxGridSelect">' ];
  23. for (var i=0, o, v; ((o=this.options[i]) !== undefined)&&((v=this.values[i]) !== undefined); i++){
  24. v = v.replace ? v.replace(/&/g, '&amp;').replace(/</g, '&lt;') : v;
  25. o = o.replace ? o.replace(/&/g, '&amp;').replace(/</g, '&lt;') : o;
  26. h.push("<option", (inDatum==v ? ' selected' : ''), ' value="' + v + '"', ">", o, "</option>");
  27. }
  28. h.push('</select>');
  29. return h.join('');
  30. }
  31. });
  32. PdSelect.markupFactory = function(node, cell){
  33. Cell.markupFactory(node, cell);
  34. var options = lang.trim(domAttr.get(node, "options")||"");
  35. if(options){
  36. var o = options.split(',');
  37. if(o[0] != options){
  38. cell.options = o;
  39. }
  40. }
  41. var values = lang.trim(domAttr.get(node, "values")||"");
  42. if(values){
  43. var v = values.split(',');
  44. if(v[0] != values){
  45. cell.values = v;
  46. }
  47. }
  48. };
  49. return PdSelect;
  50. });