Ext js dynamic loading JavaScript Create form method _javascript Tips

Source: Internet
Author: User

JavaScript does not need to be compiled to run, which allows JavaScript-built applications to become flexible. We can dynamically load JavaScript scripts from the server as needed to create and control the UI to interact with the user. The following combination of Ext JS to explain how to dynamically load JS script from the server to create the form dynamically.
1 Project Structure:
the project structure is as follows: The Getjsui general handler is used to crawl the UI configuration from the database table and return it to the client; Contents folder with HTML files and JS library.

2 database table structure
You can create a table in MSSQL with the following SQL, where the Javascriptcontent field stores the specific JS script.

CREATE TABLE [dbo]. [Ext_dynamic_form] (
 [ID] [nvarchar] (m) not NULL,
 [uniname] [nvarchar] null,
 [javascriptcontent] [nvarchar] (4000) NULL,
 [Memo] [nvarchar] () NULL,
 CONSTRAINT [Pk_ext_dynamic_form] PRIMARY KEY CLUSTERED 
(
 [ID] ASC
)
) on [PRIMARY]

Once created, you can initialize the data:

Once created, you can initialize the data:

4 Getjsui Programming

Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Web;
Using Cmclouddbhelper;
Namespace EXTJS6. Services
{
 ///<summary>
 ///author:jackwangcumt
 ///</summary> Public
 class Getjsui:ihttphandler
 {public

 void ProcessRequest (HttpContext context)
 {
  string js = "";
  Context. Response.ContentType = "Text/plain";
  Context. Response.ContentType = "Text/javascript";
  Cmcdataaccess da = new cmcdataaccess ();
  String Sqlforjs = "SELECT * from Ext_dynamic_form where id= ' 006 '";
  System.Data.DataTable dt= da. Getdatatable (SQLFORJS);
  if (dt!=null)
  {
  if (dt). Rows.count==1)
  {
   js = dt. rows[0]["Javascriptcontent"]. ToString ();
  }

  }
  
  Utf-8 context
  . response.contentencoding = System.Text.Encoding.UTF8;
  Context. Response.Write (JS);

 }

 public bool IsReusable
 {
  get
  {return
  false;
}}}

5 Main interface HTML

 

6 run

So we can do a main framework, and then build a common system such as menus and permissions, through the configuration of the database menu and UI, can dynamically expand the application.

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.