需求:点击微信公众号列表,查看该公众号对应的应用,并通过插件干预;
效果图:
公众号列表sql数据源:select fid,fname from t_bas_wxofficialacc
应用列表sql数据源:select fid,fentryid,fagentname from t_bas_wxofficialagent where 1=1
公众号列表点击事件代码示例:
应用列表根据公众号id进行过滤的代码示例:
应用列表插件干预数据源结果示例:
完整代码:
public override void TableFieldRowClick(TableFieldRowClickEventArgs e)
{
base.TableFieldRowClick(e);
if (e.Key.ToUpper().Equals("F_MOB_TABLEFIELD"))
{
MobileShowParameter param = new MobileShowParameter();
param.FormId = "MOB_dbAgg";
string json = this.Model.GetValue(e.Key).ToString();
JObject obj = JObject.Parse(json);
string fid = obj["rows"][e.Row - 1].Last["fid"].ToString();
param.CustomParams.Add("fid", fid);
this.View.ShowForm(param, new Action<FormResult>((res) =>
{
this.View.Refresh();
}));
}
}
public override void BeforeLoadReportData(BeforeLoadReportDataEventArgs e)
{
base.BeforeLoadReportData(e);
if (e.Key.ToUpper().Equals("F_MOB_TABLEFIELD2"))
{
string fid = this.View.OpenParameter.GetCustomParameter("fid").ToString();
e.SQL += string.Format(" and fid = {0}", fid);
}
}
public override void AfterBindData(EventArgs e)
{
base.AfterBindData(e);
string formId = this.View.OpenParameter.FormId;
if (formId.ToUpper().Equals("MOB_DBAGG"))
{
string json = this.Model.GetValue("F_MOB_TABLEFIELD2").ToString();
JObject obj = JObject.Parse(json);
obj["rows"][1].Last["fagentname"] += "666";
this.Model.SetValue("F_MOB_TABLEFIELD2", obj.ToString());
this.View.UpdateView("F_MOB_TABLEFIELD2");
}
}
推荐阅读