From 79e0a36fdf9a2bb34e0245b53e6a5077b428affa Mon Sep 17 00:00:00 2001 From: totoro Date: Sat, 14 May 2022 14:20:49 +0200 Subject: [PATCH] replace select by select2 in jqgrid --- view/jqgrid.anubis | 29 +++++++++++++++++++++-------- view/view_table_renderer.anubis | 19 +++++++++++++------ 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/view/jqgrid.anubis b/view/jqgrid.anubis index df7ca30..26bfb87 100644 --- a/view/jqgrid.anubis +++ b/view/jqgrid.anubis @@ -18,12 +18,12 @@ define String ( List((List(CoreAttrs), WebArgValue, String)) from_hk_selector )= - logDebug("to_jqGrid_selector: entry"); + //logDebug("to_jqGrid_selector: entry"); with start_time = unow, with result = "\""+ join(";",map(((List(CoreAttrs), WebArgValue, String) select) |-> since select is (_, wav, show), wav.value+":"+show, from_hk_selector))+ "\"", - logDebug(show_duration_string("to_jqGrid_selector: duration ", start_time)); + //logDebug(show_duration_string("to_jqGrid_selector: duration ", start_time)); result . @@ -118,22 +118,35 @@ define String text(label,column_name,help) then "{ name: \""+column_name+"\", label: \""+_T(label)+"\", editable:true, autoResizable: true, "+search_options(column_name)+" }", password(label,column_name,help) then "{ name: \""+column_name+"\", label: \""+_T(label)+"\", autoResizable: true }", foreign_text(label,column_name,selector,help) then + logDebug("to_jqGrid_ColModel 1: foreign_text column_name "+column_name); with jqgrid_selector = to_jqGrid_selector(selector.get(db,table_referer,"")), - "{ name: \""+column_name+"\", label: \""+_T(label)+"\", editable:true, autoResizable: true, edittype:\"select\", editoptions:{value: "+jqgrid_selector+"},"+ - " formatter: \"select\","+ - " formatoptions:{value: "+jqgrid_selector+"},"+ + "{ name: '"+column_name+"', label: '"+_T(label)+"', editable:true, autoResizable: true, edittype:'select', editoptions: {value: "+jqgrid_selector+", dataInit: function (elem) { + $(elem).select2({ + dropdownCssClass: 'ui-widget ui-jqdialog', + width: '100%' + }); +}},"+ + //" formatter: \"select\","+ + //" formatoptions:{value: "+jqgrid_selector+"},"+ "}", choices_text(label,column_name,selector,help) then + logDebug("to_jqGrid_ColModel 1: choices_text column_name "+column_name); with jqgrid_selector = to_jqGrid_selector(selector.get(db, empty_referer, "")), - "{ name: \""+column_name+"\", label: \""+_T(label)+"\", editable:true, autoResizable: true, edittype:\"select\", editoptions:{value: "+jqgrid_selector+"},"+ - " formatter: \"select\","+ - " formatoptions:{value: "+jqgrid_selector+"},"+ + "{ name: '"+column_name+"', label: '"+_T(label)+"', editable:true, autoResizable: true, edittype:'select', editoptions:{value: "+jqgrid_selector+",dataInit: function (elem) { + $(elem).select2({ + dropdownCssClass: 'ui-widget ui-jqdialog', + width: '100%' + }); +}},"+ + //" formatter: \"select\","+ + //" formatoptions:{value: "+jqgrid_selector+"},"+ "}", text_area(label,column_name,help) then "{ name: \""+column_name+"\", label: \""+_T(label)+"\" }", boolean(label,column_name,help) then "{ name: \""+column_name+"\", label: \""+_T(label)+"\", editable:true, autoResizable: true, template: \"booleanCheckboxFa\" }", integer(label,column_name,help) then "{ name: \""+column_name+"\", label: \""+_T(label)+"\", editable:true, autoResizable: true, template: \"integer\" }", float(label,column_name,help) then "{ name: \""+column_name+"\", label: \""+_T(label)+"\", editable:true, autoResizable: true, template: \"number\" }", choices_int(label,column_name,selector,help) then + logDebug("to_jqGrid_ColModel 1: choices_int column_name "+column_name); with jqgrid_selector = to_jqGrid_selector(selector.get(db, empty_referer, "")), "{ name: \""+column_name+"\", label: \""+_T(label)+"\", editable:true, autoResizable: true, edittype:\"select\", editoptions:{value: "+jqgrid_selector+"},"+ " formatter: \"select\","+ diff --git a/view/view_table_renderer.anubis b/view/view_table_renderer.anubis index e694295..215dfd7 100644 --- a/view/view_table_renderer.anubis +++ b/view/view_table_renderer.anubis @@ -379,7 +379,7 @@ define String )= logDebug("jqGrid_options: entry"); with result = " - editurl: '?aws_controller=hk_c&aws_action=grid_action&table_name="+rows.table_name+"', + editurl: '?aws_c=hk_c&aws_a=grid_action&table_name="+rows.table_name+"', iconSet: \"fontAwesome\", cmTemplate: { autoResizable: true}, autoResizing: { compact: true, resetWidthOrg: true }, @@ -394,8 +394,8 @@ define String rowList:[5,10,20,30,50], cellEdit: false, cellsubmit: 'remote', - cellurl: '?aws_controller=hk_c&aws_action=grid_action&table_name="+rows.table_name+"', - editurl: '?aws_controller=hk_c&aws_action=grid_action&table_name="+rows.table_name+"', + cellurl: '?aws_c=hk_c&aws_a=grid_action&table_name="+rows.table_name+"', + editurl: '?aws_c=hk_c&aws_a=grid_action&table_name="+rows.table_name+"', onSelectRow: function (rowid, status, e) { var $self = $(this), savedRow = $self.jqGrid(\"getGridParam\", \"savedRow\"); if (savedRow.length > 0 && savedRow[0].id !== rowid) { @@ -462,7 +462,7 @@ public define HTML_Partial_Content logDebug("jqGrid_table: entry"); with filter_clause = if clause = "" then "" else "&clause="+url_quote(clause), with referer_arg = "&"+to_Web_arg(table_referer, ""), - with js = js_inline(jquery_ready( + with js_init = js_inline(jquery_ready( "var lastSel; initAutocomplete = function (elem, cmName) { $(elem).autocomplete({ @@ -518,7 +518,10 @@ url:'?aws_controller=hk_c&aws_action=grid_view&table_name="+rows.table_name+"&vi return ret; }")), logDebug("jqGrid_table: partial_content"); - partial_content(jqgrid_init(lang) + [js, css(css_file("hayamiki/css/hayamiki.css"))], + partial_content(jqgrid_init(lang) + [js_init, + css(css_file("hayamiki/css/hayamiki.css")), + js(js_file("select2/js/select2.full.js")), + css(css_file("select2/css/select2.css"))], div([], sequence([ table([core_attrs([id(uid+"_grid")])],[]), @@ -753,7 +756,7 @@ public define List(CXM_Form_Field) //Get the priority of the web argument content for the value, this means the value already set by the user or called with programmaticaly with it with value = get_DB_id(lwa, c_name, _value), //create refresh function and call it first to construct the dropdown - with load_script = script("text/javascript","function "+refresh_func+"() { Xlib.load_content('"+uid+foreign_table_name+"_"+c_name+"_selector', '?aws_controller=hk_c&aws_action=selector&table_name="+foreign_table_name+"&fk_filter="+fk_clause+"&selected="+value+"&"+to_Web_arg(table_referer, "")+"');} "+refresh_func+"(); "), + with load_script = script("text/javascript","function "+refresh_func+"() { Xlib.load_content('"+uid+foreign_table_name+"_"+c_name+"_selector', '?aws_c=hk_c&aws_a=selector&table_name="+foreign_table_name+"&fk_filter="+fk_clause+"&selected="+value+"&"+to_Web_arg(table_referer, "")+"'); $('#"+uid+foreign_table_name+"_"+c_name+"_selector').select2();} "+refresh_func+"(); "), [ partial(jq_dialog_create(dialog_id(uid+foreign_table_name+"_dlg_ajax"), ajax(controller_action("hk_c", "ajax_edit_table&dialog_id="+uid+foreign_table_name+"_dlg_ajax&sub_dialog=true&table_name="+foreign_table_name+"&after_close_cb="+refresh_func)))), one_line_fields([ @@ -889,6 +892,8 @@ public define HTML_Partial_Content partial_content( [ js(js_file("hayamiki/js/jscolor.min.js")), js(js_file("xlib/js/dropzone.js")), + js(js_file("select2/js/select2.full.min.js")), + css(css_file("select2/css/select2.min.css")), js_inline(jquery_ready("Dropzone.options.myAwesomeDropzone = { maxFiles: 100, dictDefaultMessage : \""+_T("DROP_FILE_HERE")+"\", @@ -1044,6 +1049,8 @@ public define List(CXM_Form_Field) partial(partial_content([ js(js_file("ajax-combobox/js/jquery.ajax-combobox.js")), css(css_file("ajax-combobox/css/jquery.ajax-combobox.css")), + js(js_file("select2/js/select2.full.min.js")), + css(css_file("select2/css/select2.min.css")), js_inline(jquery_ready(combo_init))], jq_dialog_create(dialog_id(uid+foreign_table_name+"_dlg_ajax"), ajax(controller_action("hk_c", "ajax_edit_table&dialog_id="+uid+foreign_table_name+"_dlg_ajax&sub_dialog=true&table_name="+foreign_table_name))))), one_line_fields([ -- libgit2 0.21.4