private void GenDetailBlock(String TemplateName) { MWizard.TBlockItem BlockItem = null; foreach (TBlockItem B in FClientData.Blocks) { if (B.wDataSource == null) { BlockItem = B; break; } } #if VS90 JQDefault Default = new JQDefault(); Default.ID = "defaultDetail"; // +BlockItem.TableName; Default.BindingObjectID = "dataGridDetail"; JQValidate Validate = new JQValidate(); Validate.ID = "validateDetail"; // +BlockItem.TableName; Validate.BindingObjectID = "dataGridDetail"; WebQueryFiledsCollection QueryFields = new WebQueryFiledsCollection(null, typeof(QueryField)); WebQueryColumnsCollection QueryColumns = new WebQueryColumnsCollection(null, typeof(QueryColumns)); foreach (TBlockFieldItem fielditem in BlockItem.BlockFieldItems) { GenDefault(fielditem, Default, Validate); GenQuery(fielditem, QueryFields, QueryColumns, BlockItem.TableName); } object oJQDialog1 = FDesignerDocument.webControls.item("JQDialog1", 0); WebDevPage.IHTMLElement eJQDialog1 = (WebDevPage.IHTMLElement)oJQDialog1; //object oJQFormViewMaster = FDesignerDocument.webControls.item("dataFormMaster", 0); //WebDevPage.IHTMLElement eJQFormViewMaster = (WebDevPage.IHTMLElement)oJQFormViewMaster; if (oJQDialog1 != null) { ((WebDevPage.IHTMLElement)oJQDialog1).setAttribute("Title", FClientData.FormTitle, 0); StringBuilder sb = new StringBuilder(); String detailEditDialogID = String.Empty; if (FClientData.BaseFormName == "JQueryMasterDetail2") { detailEditDialogID = "EditDialogID=\"JQDialog2\""; } sb.AppendFormat("<JQTools:JQDataGrid ID=\"dataGridDetail\" runat=\"server\" DataMember=\"{0}\" RemoteName=\"{1}\" Title=\"明細資料\"" + "AutoApply=\"False\" Pagination=\"False\" ParentObjectID=\"dataFormMaster\" {2}>", BlockItem.TableName, FClientData.ProviderName, detailEditDialogID); sb.Append("<Columns>"); foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems) { if ((BFI.ControlType == "ComboBox" || BFI.ControlType == "ComboGrid" || BFI.ControlType == "RefValBox") && (string.IsNullOrEmpty(BFI.ComboValueField) || string.IsNullOrEmpty(BFI.ComboTextField) || string.IsNullOrEmpty(BFI.ComboRemoteName) || string.IsNullOrEmpty(BFI.ComboEntityName))) { BFI.ControlType = "TextBox"; } String sHeaderText = String.IsNullOrEmpty(BFI.Description) ? BFI.DataField : BFI.Description; if (BFI.ControlType == "ComboBox") { sb.Append(String.Format("<JQTools:JQGridColumn Alignment=\"left\" Editor=\"infocombobox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" " + "EditorOptions=\"remoteName:'{4}',tableName:'{5}',valueField:'{2}',textField:'{3}'\" Format=\"{6}\"/>", BFI.DataField, sHeaderText, BFI.ComboValueField, BFI.ComboTextField, BFI.ComboRemoteName, BFI.ComboEntityName, BFI.EditMask)); } else if (BFI.ControlType == "ComboGrid") { //EditorOptions=",url:'../handler/jqDataHandle.ashx?RemoteName=SCustomers.Customers&TableName=Customers',columns:[[{field:'CustomerID',title:'CustomerID',width:80,align:'left'}]]" /> String columns = "{field:'" + BFI.ComboValueField + "',title:'" + BFI.ComboValueFieldCaption + "',width:80,align:'left'}"; if (BFI.ComboValueField != BFI.ComboTextField) { columns += ",{field:'" + BFI.ComboTextField + "',title:'" + BFI.ComboTextFieldCaption + "',width:80,align:'left'}"; } sb.Append(String.Format("<JQTools:JQGridColumn Alignment=\"left\" Editor=\"infocombogrid\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" " + "EditorOptions=\"panelWidth:350,remoteName:'{4}',tableName:'{5}',valueField:'{2}',textField:'{3}',valueFieldCaption:'{7}',textFieldCaption:'{8}',columns:[{6}]\" Format=\"{9}\"/>", BFI.DataField, sHeaderText, BFI.ComboValueField, BFI.ComboTextField, BFI.ComboRemoteName, BFI.ComboEntityName, columns, BFI.ComboValueFieldCaption, BFI.ComboTextFieldCaption, BFI.EditMask)); } else if (BFI.ControlType == "RefValBox") { //EditorOptions="title:'JQRefval',panelWidth:350,remoteName:'SCustomers.Customer',tableName:'Customer',columns:[{field:'CustomerID',title:'CustomerID',width:80,align:'left'},{field:'CompanyName',title:'CompanyName',width:80,align:'left'}],columnMatches:[],valueField:'CustomerID'" String columns = "{field:'" + BFI.ComboValueField + "',title:'" + BFI.ComboValueFieldCaption + "',width:80,align:'left'}"; if (BFI.ComboValueField != BFI.ComboTextField) { columns += ",{field:'" + BFI.ComboTextField + "',title:'" + BFI.ComboTextFieldCaption + "',width:80,align:'left'}"; } sb.Append(String.Format("<JQTools:JQGridColumn Alignment=\"left\" Editor=\"inforefval\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" " + "EditorOptions=\"title:'JQRefval',panelWidth:350,columnMatches:[],remoteName:'{4}',tableName:'{5}',valueField:'{2}',textField:'{3}',valueFieldCaption:'{7}',textFieldCaption:'{8}',columns:[{6}]\" Format=\"{9}\"/>", BFI.DataField, sHeaderText, BFI.ComboValueField, BFI.ComboTextField, BFI.ComboRemoteName, BFI.ComboEntityName, columns, BFI.ComboValueFieldCaption, BFI.ComboTextFieldCaption, BFI.EditMask)); } else if (BFI.ControlType == "CheckBox") { sb.Append(String.Format("<JQTools:JQGridColumn Alignment=\"left\" Editor=\"checkbox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" />", BFI.DataField, sHeaderText)); } else { if (BFI.DataType == typeof(DateTime) || (BFI.ControlType != null && BFI.ControlType == "DateTimeBox")) { sb.Append(String.Format("<JQTools:JQGridColumn Alignment=\"left\" Editor=\"datebox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" Format=\"{2}\"/>", BFI.DataField, sHeaderText, BFI.EditMask)); } else if (BFI.DataType == typeof(Int16) || BFI.DataType == typeof(Int32) || BFI.DataType == typeof(Int64) || BFI.DataType == typeof(float) || BFI.DataType == typeof(double) || BFI.DataType == typeof(decimal) || (BFI.ControlType != null && BFI.ControlType == "NumberBox")) { sb.Append(String.Format("<JQTools:JQGridColumn Alignment=\"right\" Editor=\"numberbox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" Format=\"{2}\"/>", BFI.DataField, sHeaderText, BFI.EditMask)); } else { sb.Append(String.Format("<JQTools:JQGridColumn Alignment=\"left\" Editor=\"text\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" Format=\"{2}\"/>", BFI.DataField, sHeaderText, BFI.EditMask)); } } } sb.Append("</Columns>"); if (BlockItem.Relation != null && BlockItem.Relation.ChildColumns.Length > 0) { sb.Append("<RelationColumns>"); for (int i = 0; i < BlockItem.Relation.ChildColumns.Length; i++) { sb.AppendFormat("<JQTools:JQRelationColumn FieldName=\"{0}\" ParentFieldName=\"{1}\" />", BlockItem.Relation.ChildColumns[i].ColumnName, BlockItem.Relation.ParentColumns[i].ColumnName); } sb.Append("</RelationColumns>"); } sb.Append("<TooItems>"); sb.Append("<JQTools:JQToolItem Icon=\"icon-add\" ItemType=\"easyui-linkbutton\" OnClick=\"insertItem\" Text=\"新增\" />"); sb.Append("<JQTools:JQToolItem Icon=\"icon-edit\" ItemType=\"easyui-linkbutton\" OnClick=\"updateItem\" Text=\"更改\" />"); sb.Append("<JQTools:JQToolItem Icon=\"icon-remove\" ItemType=\"easyui-linkbutton\" OnClick=\"deleteItem\" Text=\"刪除\" />"); sb.Append("</TooItems>"); sb.Append("</JQTools:JQDataGrid>"); eJQDialog1.innerHTML = eJQDialog1.innerHTML.Replace("<JQTools:JQDataGrid ID=\"dataGridDetail\" runat=\"server\" />", sb.ToString()); object ojqDialog2 = FDesignerDocument.webControls.item("JQDialog2", 0); if (ojqDialog2 == null) { eJQDialog1.innerHTML += GetControlXml(Default); eJQDialog1.innerHTML += GetControlXml(Validate); } } //object oJQFormViewMaster = FDesignerDocument.webControls.item("dataFormMaster", 0); //WebDevPage.IHTMLElement eJQFormViewMaster = (WebDevPage.IHTMLElement)oJQFormViewMaster; object oJQDialog2 = FDesignerDocument.webControls.item("JQDialog2", 0); WebDevPage.IHTMLElement eJQDialog2 = (WebDevPage.IHTMLElement)oJQDialog2; if (oJQDialog2 != null) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("<JQTools:JQDataForm ID=\"dataFormDetail\" runat=\"server\" HorizontalColumnsCount=\"2\" DataMember=\"{0}\" RemoteName=\"{1}\" ParentObjectID=\"dataFormMaster\" >", BlockItem.TableName, FClientData.ProviderName); sb.Append("<Columns>"); foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems) { if ((BFI.ControlType == "ComboBox" || BFI.ControlType == "ComboGrid" || BFI.ControlType == "RefValBox") && (string.IsNullOrEmpty(BFI.ComboValueField) || string.IsNullOrEmpty(BFI.ComboTextField) || string.IsNullOrEmpty(BFI.ComboRemoteName) || string.IsNullOrEmpty(BFI.ComboEntityName))) { BFI.ControlType = "TextBox"; } String sHeaderText = String.IsNullOrEmpty(BFI.Description) ? BFI.DataField : BFI.Description; if (BFI.ControlType == "ComboBox") { sb.Append(String.Format("<JQTools:JQFormColumn Alignment=\"left\" Editor=\"infocombobox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" " + "EditorOptions=\"remoteName:'{4}',tableName:'{5}',valueField:'{2}',textField:'{3}'\" Format=\"{6}\"/>", BFI.DataField, sHeaderText, BFI.ComboValueField, BFI.ComboTextField, BFI.ComboRemoteName, BFI.ComboEntityName, BFI.EditMask)); } else if (BFI.ControlType == "ComboGrid") { //EditorOptions=",url:'../handler/jqDataHandle.ashx?RemoteName=SCustomers.Customers&TableName=Customers',columns:[[{field:'CustomerID',title:'CustomerID',width:80,align:'left'}]]" /> String columns = "{field:'" + BFI.ComboValueField + "',title:'" + BFI.ComboValueFieldCaption + "',width:80,align:'left'}"; if (BFI.ComboValueField != BFI.ComboTextField) { columns += ",{field:'" + BFI.ComboTextField + "',title:'" + BFI.ComboTextFieldCaption + "',width:80,align:'left'}"; } sb.Append(String.Format("<JQTools:JQFormColumn Alignment=\"left\" Editor=\"infocombogrid\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" " + "EditorOptions=\"panelWidth:350,remoteName:'{4}',tableName:'{5}',valueField:'{2}',textField:'{3}',valueFieldCaption:'{7}',textFieldCaption:'{8}',columns:[{6}]\" Format=\"{9}\"/>", BFI.DataField, sHeaderText, BFI.ComboValueField, BFI.ComboTextField, BFI.ComboRemoteName, BFI.ComboEntityName, columns, BFI.ComboValueFieldCaption, BFI.ComboTextFieldCaption, BFI.EditMask)); } else if (BFI.ControlType == "RefValBox") { //EditorOptions="title:'JQRefval',panelWidth:350,remoteName:'SCustomers.Customer',tableName:'Customer',columns:[{field:'CustomerID',title:'CustomerID',width:80,align:'left'},{field:'CompanyName',title:'CompanyName',width:80,align:'left'}],columnMatches:[],valueField:'CustomerID'" String columns = "{field:'" + BFI.ComboValueField + "',title:'" + BFI.ComboValueFieldCaption + "',width:80,align:'left'}"; if (BFI.ComboValueField != BFI.ComboTextField) { columns += ",{field:'" + BFI.ComboTextField + "',title:'" + BFI.ComboTextFieldCaption + "',width:80,align:'left'}"; } sb.Append(String.Format("<JQTools:JQFormColumn Alignment=\"left\" Editor=\"inforefval\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" " + "EditorOptions=\"title:'JQRefval',panelWidth:350,columnMatches:[],remoteName:'{4}',tableName:'{5}',valueField:'{2}',textField:'{3}',valueFieldCaption:'{7}',textFieldCaption:'{8}',columns:[{6}]\" Format=\"{9}\"/>", BFI.DataField, sHeaderText, BFI.ComboValueField, BFI.ComboTextField, BFI.ComboRemoteName, BFI.ComboEntityName, columns, BFI.ComboValueFieldCaption, BFI.ComboTextFieldCaption, BFI.EditMask)); } else if (BFI.ControlType == "CheckBox") { sb.Append(String.Format("<JQTools:JQFormColumn Alignment=\"left\" Editor=\"checkbox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" />", BFI.DataField, sHeaderText)); } else { if (BFI.DataType == typeof(DateTime) || (BFI.ControlType != null && BFI.ControlType == "DateTimeBox")) { sb.Append(String.Format("<JQTools:JQFormColumn Alignment=\"left\" Editor=\"datebox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" Format=\"{2}\"/>", BFI.DataField, sHeaderText, BFI.EditMask)); } else if (BFI.DataType == typeof(Int16) || BFI.DataType == typeof(Int32) || BFI.DataType == typeof(Int64) || BFI.DataType == typeof(float) || BFI.DataType == typeof(double) || BFI.DataType == typeof(decimal) || (BFI.ControlType != null && BFI.ControlType == "NumberBox")) { sb.Append(String.Format("<JQTools:JQFormColumn Alignment=\"left\" Editor=\"numberbox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" Format=\"{2}\"/>", BFI.DataField, sHeaderText, BFI.EditMask)); } else { sb.Append(String.Format("<JQTools:JQFormColumn Alignment=\"left\" Editor=\"text\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" Format=\"{2}\"/>", BFI.DataField, sHeaderText, BFI.EditMask)); } } } sb.Append("</Columns>"); if (BlockItem.Relation != null && BlockItem.Relation.ChildColumns.Length > 0) { sb.Append("<RelationColumns>"); for (int i = 0; i < BlockItem.Relation.ChildColumns.Length; i++) { sb.AppendFormat("<JQTools:JQRelationColumn FieldName=\"{0}\" ParentFieldName=\"{1}\" />", BlockItem.Relation.ChildColumns[i].ColumnName, BlockItem.Relation.ParentColumns[i].ColumnName); } sb.Append("</RelationColumns>"); } sb.Append("</JQTools:JQDataForm>"); eJQDialog2.innerHTML = eJQDialog2.innerHTML.Replace("<JQTools:JQDataForm ID=\"dataFormDetail\" runat=\"server\" ParentObjectID=\"dataFormMaster\" />", sb.ToString()); Default.BindingObjectID = "dataFormDetail"; eJQDialog1.innerHTML += GetControlXml(Default); Validate.BindingObjectID = "dataFormDetail"; eJQDialog1.innerHTML += GetControlXml(Validate); } #else #endif }
private void GenMainBlockControl(TBlockItem BlockItem) { #if VS90 //object oMaster = FDesignerDocument.webControls.item("Master", 0); //WebDevPage.IHTMLElement eMaster = null; //if (oMaster == null || !(oMaster is WebDevPage.IHTMLElement)) // return; //eMaster = (WebDevPage.IHTMLElement)oMaster; BlockItem.wDataSource = new WebDataSource(); JQDefault Default = new JQDefault(); Default.ID = "defaultMaster"; // +BlockItem.TableName; Default.BindingObjectID = "dataGridMaster"; JQValidate Validate = new JQValidate(); Validate.ID = "validateMaster"; // +BlockItem.TableName; Validate.BindingObjectID = "dataGridMaster"; WebQueryFiledsCollection QueryFields = new WebQueryFiledsCollection(null, typeof(QueryField)); WebQueryColumnsCollection QueryColumns = new WebQueryColumnsCollection(null, typeof(QueryColumns)); foreach (TBlockFieldItem fielditem in BlockItem.BlockFieldItems) { GenDefault(fielditem, Default, Validate); GenQuery(fielditem, QueryFields, QueryColumns, BlockItem.TableName); } object oJQGridViewMaster = FDesignerDocument.webControls.item("dataGridMaster", 0); WebDevPage.IHTMLElement eJQGridViewMaster = (WebDevPage.IHTMLElement)oJQGridViewMaster; //FClientData.ProviderName if (eJQGridViewMaster != null) { ((WebDevPage.IHTMLElement)oJQGridViewMaster).setAttribute("RemoteName", FClientData.ProviderName, 0); ((WebDevPage.IHTMLElement)oJQGridViewMaster).setAttribute("DataMember", FClientData.TableName, 0); ((WebDevPage.IHTMLElement)oJQGridViewMaster).setAttribute("Title", FClientData.FormTitle, 0); //这里本来想再往下找Columns节点的,可是找不到,只能先这样写了 StringBuilder sb = new StringBuilder(eJQGridViewMaster.innerHTML); int idx = eJQGridViewMaster.innerHTML.IndexOf("</Columns>"); List<string> KeyFields = new List<string>(); foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems) { //if (BFI.HideGridColumn) //{ // continue; //} if ((BFI.ControlType == "ComboBox" || BFI.ControlType == "ComboGrid" || BFI.ControlType == "RefValBox") && (string.IsNullOrEmpty(BFI.ComboValueField) || string.IsNullOrEmpty(BFI.ComboTextField) || string.IsNullOrEmpty(BFI.ComboRemoteName) || string.IsNullOrEmpty(BFI.ComboEntityName))) { BFI.ControlType = "TextBox"; } if (BFI.IsKey) KeyFields.Add(BFI.DataField); idx = sb.ToString().LastIndexOf("</Columns>"); String sHeaderText = String.IsNullOrEmpty(BFI.Description) ? BFI.DataField : BFI.Description; if (BFI.ControlType == "ComboBox") { sb.Insert(idx, String.Format("<JQTools:JQGridColumn Alignment=\"left\" Editor=\"infocombobox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" " + "EditorOptions=\"remoteName:'{4}',tableName:'{5}',valueField:'{2}',textField:'{3}'\" Format=\"{6}\"/>", BFI.DataField, sHeaderText, BFI.ComboValueField, BFI.ComboTextField, BFI.ComboRemoteName, BFI.ComboEntityName, BFI.EditMask)); } else if (BFI.ControlType == "ComboGrid") { //EditorOptions=",url:'../handler/jqDataHandle.ashx?RemoteName=SCustomers.Customers&TableName=Customers',columns:[[{field:'CustomerID',title:'CustomerID',width:80,align:'left'}]]" /> String columns = "{field:'" + BFI.ComboValueField + "',title:'" + BFI.ComboValueFieldCaption + "',width:80,align:'left'}"; if (BFI.ComboValueField != BFI.ComboTextField) { columns += ",{field:'" + BFI.ComboTextField + "',title:'" + BFI.ComboTextFieldCaption + "',width:80,align:'left'}"; } sb.Insert(idx, String.Format("<JQTools:JQGridColumn Alignment=\"left\" Editor=\"infocombogrid\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" " + "EditorOptions=\"panelWidth:350,remoteName:'{4}',tableName:'{5}',valueField:'{2}',textField:'{3}',valueFieldCaption:'{7}',textFieldCaption:'{8}',columns:[{6}]\" Format=\"{9}\"/>", BFI.DataField, sHeaderText, BFI.ComboValueField, BFI.ComboTextField, BFI.ComboRemoteName, BFI.ComboEntityName, columns, BFI.ComboValueFieldCaption, BFI.ComboTextFieldCaption, BFI.EditMask)); } else if (BFI.ControlType == "RefValBox") { //EditorOptions="title:'JQRefval',panelWidth:350,remoteName:'SCustomers.Customer',tableName:'Customer',columns:[{field:'CustomerID',title:'CustomerID',width:80,align:'left'},{field:'CompanyName',title:'CompanyName',width:80,align:'left'}],columnMatches:[],valueField:'CustomerID'" String columns = "{field:'" + BFI.ComboValueField + "',title:'" + BFI.ComboValueFieldCaption + "',width:80,align:'left'}"; if (BFI.ComboValueField != BFI.ComboTextField) { columns += ",{field:'" + BFI.ComboTextField + "',title:'" + BFI.ComboTextFieldCaption + "',width:80,align:'left'}"; } sb.Insert(idx, String.Format("<JQTools:JQGridColumn Alignment=\"left\" Editor=\"inforefval\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" " + "EditorOptions=\"title:'JQRefval',panelWidth:350,columnMatches:[],remoteName:'{4}',tableName:'{5}',valueField:'{2}',textField:'{3}',valueFieldCaption:'{7}',textFieldCaption:'{8}',columns:[{6}]\" Format=\"{9}\"/>", BFI.DataField, sHeaderText, BFI.ComboValueField, BFI.ComboTextField, BFI.ComboRemoteName, BFI.ComboEntityName, columns, BFI.ComboValueFieldCaption, BFI.ComboTextFieldCaption, BFI.EditMask)); } else if (BFI.ControlType == "CheckBox") { sb.Insert(idx, String.Format("<JQTools:JQGridColumn Alignment=\"left\" Editor=\"checkbox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" />", BFI.DataField, sHeaderText)); } else { if (BFI.DataType == typeof(DateTime) || (BFI.ControlType != null && BFI.ControlType == "DateTimeBox")) { sb.Insert(idx, String.Format("<JQTools:JQGridColumn Alignment=\"left\" Editor=\"datebox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" Format=\"{2}\"/>", BFI.DataField, sHeaderText, BFI.EditMask)); } else if (BFI.DataType == typeof(Int16) || BFI.DataType == typeof(Int32) || BFI.DataType == typeof(Int64) || BFI.DataType == typeof(float) || BFI.DataType == typeof(double) || BFI.DataType == typeof(decimal) || (BFI.ControlType != null && BFI.ControlType == "NumberBox")) { sb.Insert(idx, String.Format("<JQTools:JQGridColumn Alignment=\"right\" Editor=\"numberbox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" Format=\"{2}\"/>", BFI.DataField, sHeaderText, BFI.EditMask)); } else { String maxLength = ""; if (BFI.DataType == typeof(String)) { maxLength = " MaxLength=\"" + BFI.Length.ToString() + "\" "; } sb.Insert(idx, String.Format("<JQTools:JQGridColumn Alignment=\"left\" Editor=\"text\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" {2} Format=\"{3}\"/>", BFI.DataField, sHeaderText, maxLength, BFI.EditMask)); } } } //eWebGridView1.innerHTML = sb.ToString(); //StringBuilder sbQuery = new StringBuilder(sb.ToString()); int idxQuery = sb.ToString().LastIndexOf("</QueryColumns>"); foreach (WebQueryField item in QueryFields) { idxQuery = sb.ToString().LastIndexOf("</QueryColumns>"); sb.Insert(idxQuery, item.Mode); //sb.Insert(idxQuery, String.Format("<JQTools:JQQueryColumn Caption=\"{0}\" Condition=\"{1}\" Editor=\"text\" FieldName=\"{2}\" />", item.Caption, item.Operator, item.Column)); } eJQGridViewMaster.innerHTML = sb.ToString(); String sKeyFieldName = ""; foreach (var item in KeyFields) { sKeyFieldName += item + ";"; } eJQGridViewMaster.outerHTML = eJQGridViewMaster.outerHTML.Replace("KeyFieldName=\"\"", String.Format("KeyFieldName=\"{0}\"", sKeyFieldName)); } object oJQDialog1 = FDesignerDocument.webControls.item("JQDialog1", 0); WebDevPage.IHTMLElement eJQDialog1 = (WebDevPage.IHTMLElement)oJQDialog1; //object oJQFormViewMaster = FDesignerDocument.webControls.item("dataFormMaster", 0); //WebDevPage.IHTMLElement eJQFormViewMaster = (WebDevPage.IHTMLElement)oJQFormViewMaster; if (oJQDialog1 != null) { ((WebDevPage.IHTMLElement)oJQDialog1).setAttribute("Title", FClientData.FormTitle, 0); StringBuilder sb = new StringBuilder(); sb.AppendFormat("<JQTools:JQDataForm ID=\"dataFormMaster\" runat=\"server\" DataMember=\"{0}\" RemoteName=\"{1}\"" + "HorizontalColumnsCount=\"2\">", FClientData.TableName, FClientData.ProviderName); sb.Append("<Columns>"); foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems) { if ((BFI.ControlType == "ComboBox" || BFI.ControlType == "ComboGrid" || BFI.ControlType == "RefValBox") && (string.IsNullOrEmpty(BFI.ComboValueField) || string.IsNullOrEmpty(BFI.ComboTextField) || string.IsNullOrEmpty(BFI.ComboRemoteName) || string.IsNullOrEmpty(BFI.ComboEntityName))) { BFI.ControlType = "TextBox"; } String sHeaderText = String.IsNullOrEmpty(BFI.Description) ? BFI.DataField : BFI.Description; if (BFI.ControlType == "ComboBox") { sb.Append(String.Format("<JQTools:JQFormColumn Alignment=\"left\" Editor=\"infocombobox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"180\" " + "EditorOptions=\"remoteName:'{4}',tableName:'{5}',valueField:'{2}',textField:'{3}'\" Format=\"{6}\"/>", BFI.DataField, sHeaderText, BFI.ComboValueField, BFI.ComboTextField, BFI.ComboRemoteName, BFI.ComboEntityName, BFI.EditMask)); } else if (BFI.ControlType == "ComboGrid") { //EditorOptions=",url:'../handler/jqDataHandle.ashx?RemoteName=SCustomers.Customers&TableName=Customers',columns:[[{field:'CustomerID',title:'CustomerID',width:80,align:'left'}]]" /> String columns = "{field:'" + BFI.ComboValueField + "',title:'" + BFI.ComboValueFieldCaption + "',width:80,align:'left'}"; if (BFI.ComboValueField != BFI.ComboTextField) { columns += ",{field:'" + BFI.ComboTextField + "',title:'" + BFI.ComboTextFieldCaption + "',width:80,align:'left'}"; } sb.Append(String.Format("<JQTools:JQFormColumn Alignment=\"left\" Editor=\"infocombogrid\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"180\" " + "EditorOptions=\"panelWidth:350,remoteName:'{4}',tableName:'{5}',valueField:'{2}',textField:'{3}',valueFieldCaption:'{7}',textFieldCaption:'{8}',columns:[{6}]\" Format=\"{9}\"/>", BFI.DataField, sHeaderText, BFI.ComboValueField, BFI.ComboTextField, BFI.ComboRemoteName, BFI.ComboEntityName, columns, BFI.ComboValueFieldCaption, BFI.ComboTextFieldCaption, BFI.EditMask)); } else if (BFI.ControlType == "RefValBox") { //EditorOptions="title:'JQRefval',panelWidth:350,remoteName:'SCustomers.Customer',tableName:'Customer',columns:[{field:'CustomerID',title:'CustomerID',width:80,align:'left'},{field:'CompanyName',title:'CompanyName',width:80,align:'left'}],columnMatches:[],valueField:'CustomerID'" String columns = "{field:'" + BFI.ComboValueField + "',title:'" + BFI.ComboValueFieldCaption + "',width:80,align:'left'}"; if (BFI.ComboValueField != BFI.ComboTextField) { columns += ",{field:'" + BFI.ComboTextField + "',title:'" + BFI.ComboTextFieldCaption + "',width:80,align:'left'}"; } sb.Append(String.Format("<JQTools:JQFormColumn Alignment=\"left\" Editor=\"inforefval\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"180\" " + "EditorOptions=\"title:'JQRefval',panelWidth:350,columnMatches:[],remoteName:'{4}',tableName:'{5}',valueField:'{2}',textField:'{3}',valueFieldCaption:'{7}',textFieldCaption:'{8}',columns:[{6}]\" Format=\"{9}\"/>", BFI.DataField, sHeaderText, BFI.ComboValueField, BFI.ComboTextField, BFI.ComboRemoteName, BFI.ComboEntityName, columns, BFI.ComboValueFieldCaption, BFI.ComboTextFieldCaption, BFI.EditMask)); } else if (BFI.ControlType == "CheckBox") { sb.Append(String.Format("<JQTools:JQFormColumn Alignment=\"left\" Editor=\"checkbox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"180\" />", BFI.DataField, sHeaderText)); } else { if (BFI.DataType == typeof(DateTime) || (BFI.ControlType != null && BFI.ControlType == "DateTimeBox")) { sb.Append(String.Format("<JQTools:JQFormColumn Alignment=\"left\" Editor=\"datebox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"180\" Format=\"{2}\"/>", BFI.DataField, sHeaderText, BFI.EditMask)); } else if (BFI.DataType == typeof(Int16) || BFI.DataType == typeof(Int32) || BFI.DataType == typeof(Int64) || BFI.DataType == typeof(float) || BFI.DataType == typeof(double) || BFI.DataType == typeof(decimal) || (BFI.ControlType != null && BFI.ControlType == "NumberBox")) { sb.Append(String.Format("<JQTools:JQFormColumn Alignment=\"left\" Editor=\"numberbox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"180\" Format=\"{2}\"/>", BFI.DataField, sHeaderText, BFI.EditMask)); } else { String maxLength = ""; if (BFI.DataType == typeof(String)) { maxLength = " maxlength='" + BFI.Length.ToString() + "' "; } sb.Append(String.Format("<JQTools:JQFormColumn Alignment=\"left\" Editor=\"text\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"180\" {2} Format=\"{3}\"/>", BFI.DataField, sHeaderText, maxLength, BFI.EditMask)); } } } sb.Append("</Columns>"); sb.Append("</JQTools:JQDataForm>"); eJQDialog1.innerHTML = eJQDialog1.innerHTML.Replace("<JQTools:JQDataForm ID=\"dataFormMaster\" runat=\"server\" />", sb.ToString()); Default.BindingObjectID = "dataFormMaster"; eJQDialog1.innerHTML += GetControlXml(Default); Validate.BindingObjectID = "dataFormMaster"; eJQDialog1.innerHTML += GetControlXml(Validate); } else { if (FClientData.BaseFormName != "JQueryQuery1") { WebDevPage.IHTMLElement Page = FDesignerDocument.pageContentElement; InsertControl(Page, Default); InsertControl(Page, Validate); } } #else #endif }
private void GenDefault(TBlockFieldItem aFieldItem, JQDefault aDefault, JQValidate aValidate) { if (aFieldItem.DefaultValue != "" && aFieldItem.DefaultValue != null) { JQDefaultColumn aDefaultItem = new JQDefaultColumn(); aDefaultItem.FieldName = aFieldItem.DataField; aDefaultItem.DefaultValue = aFieldItem.DefaultValue; aDefault.Columns.Add(aDefaultItem); } if (aFieldItem.CheckNull != null && aFieldItem.CheckNull.ToUpper() == "Y") { JQValidateColumn aValidateItem = new JQValidateColumn(); aValidateItem.FieldName = aFieldItem.DataField; aValidateItem.CheckNull = aFieldItem.CheckNull.ToUpper() == "Y"; //aValidateItem.ValidateLabelLink = "Caption" + aFieldItem.DataField; aValidate.Columns.Add(aValidateItem); } }