Mercurial > hg > ChinaGisRestApi
view gis_gui/blocks/tablestructure.js @ 156:89f49aa24061
polygon-Layers
author | fknauft |
---|---|
date | Mon, 07 Feb 2011 11:49:01 +0100 |
parents | c84536a4993a |
children | efd2469d1722 |
line wrap: on
line source
guiBlocks.prototype.addTableStructureBlock = function(url, baseId, tablename, fields, uploadForm) { function getHtmlSelectFromList(optionlist, selected, attrs) { var html = "<select " + attrs + ">"; for (var i = 0; i < optionlist.length; i++) { var txt = optionlist[i]; if (txt == selected) { html += '<option selected="true">' + txt + '</option>'; } else { html += '<option>' + txt + '</option>'; } } html += "</select>"; return html; } var block = this.addBlock(url, baseId, null, function() { // function after add block finished var id = block.id; var tbl = $(block.element).find(".datatable"); $(block.element).find(".msg.create_table_upload").show(); console.debug("in tablestructureblock after block load!"); console.debug("this=", this); console.debug("block=",block); console.debug(tbl); var colheads = []; var row = []; for (var i = 0; i < fields.length; i++) { colheads.push({'sTitle': fields[i].name}); row.push(getHtmlSelectFromList(['text','number','gis_id','coord_lat','coord_lon','id'],fields[i].type,'class="type_'+fields[i].name+'"')); } // Add DataTables functionality $(tbl).dataTable({ 'aoColumns': colheads, 'aaData': [row], 'bPaginate': false, "bFilter": false, "bSort": false, "bInfo": false }); // connect create button $(block.element).find(".create_table_button").click(function() { console.debug("create table button click form=",uploadForm); // read table form $(tbl).find("select").each(function(i,el) { // we assume form and array have same ordering fields[i].type = $(this).val(); }); console.debug("table struct=",fields); // change upload file form $(uploadForm).unbind("submit"); $(uploadForm).iframePostForm({ post: blocks.uploadTableSubmitFn(null,fields), complete: blocks.uploadTableCompleteFn() }); // hide structure block $(block.element).hide(); $(uploadForm).submit(); }); $(block.element).find(".dont_create_table_button").click(function() { console.debug("dont create table button click"); $(block.element).hide(); }); // show block $(block.element).fadeIn(); }); };