コード例 #1
0
        //----------------------------------------------------------------------------------------------------
        public void Bind_ModelListElements(IMRBPattern <M, VM> mrb, string modelKey)
        {
            var jListElements = mrb.jF2("[ModelList]");

            if (jListElements == null)
            {
                return;
            }

            for (int i = 0; i < jListElements.length; i++)
            {
                var jListItem = J(jListElements[i]);

                if (modelKey == "*" || modelKey == jListItem.attr("ModelKey")) // filter based on ModelKey -- use * for all
                {
                    string modelList_CmdText = jListItem.attr("ModelList");
                    var    cmd = ModelListCommand.New1(modelList_CmdText);

                    var      tmpModelObj = JsObj.O(mrb).Property_Get(cmd.Model_Name, cmd.UseGetterMethod_Model_Name);
                    object[] optionsList = JsObj.O(tmpModelObj).Property_Get(cmd.Model_Collection, cmd.UseGetterMethod_Model_Collection).As <object[]>();
                    if (optionsList != null && optionsList.Length > 0)
                    {
                        this.Populate_SelectOptions(jListItem, cmd.Model_Collection, optionsList, cmd);
                    }
                }
            }
        }
コード例 #2
0
        //------------------------------------------------------------------------------------------ static --
        public static ModelListCommand New1(string modelList_CommandText)
        {
            var rtn = new ModelListCommand();

            rtn.ModelList_CommandText = modelList_CommandText;
            rtn.ParseCommandText();
            return(rtn);
        }
コード例 #3
0
        //----------------------------------------------------------------------------------------------------
        private void Populate_SelectOptions(jQuery jSelectElement, string listPropertiesSetting, object[] optionsObjects, ModelListCommand cmd)
        {
            jSelectElement.html("");

            for (int i = 0; i < optionsObjects.Length; i++)
            {
                var optionsObj = JsObj.O(optionsObjects[i]);

                string value = optionsObj.Property2(cmd.Item_Value, "");
                string text  = optionsObj.Property2(cmd.Item_Text, "");
                string style = optionsObj.Property2(cmd.Item_Style, "");

                string styleAttribute = "";
                if (style.Length > 0)
                {
                    styleAttribute = "style='" + style + "'";
                }

                jSelectElement.append(JsStr.StrFormat3("<option value='{0}' {1} >{2}</option>", value, styleAttribute, text));
            }
        }