▦K2 Advanced GridsDeveloper Portal / 0.23
Documentation / Getting started

Installation & deployment

Keep the engine separate from application settings. The fully external approach has been validated on the development K2 Runtime.

Deployment choices

ModeEngineConfiguration
EmbeddedData LabelData Label
External engineJS fileData Label
Fully externalJS fileJS file

The fully external method is the verified walkthrough in this release. The other modes remain documented as architectural choices; dedicated simplified examples are pending.

1. Prepare the ListView

Create a standard non-editable K2 ListView based on a SmartObject. Disable native paging for this walkthrough. See Prerequisites for the sample database and columns.

2. Prepare the SmartForm

Place the ListView on a SmartForm in K2 Designer, configure its initialization rule to load the records, save the form and open it in Runtime. Confirm the unmodified list works before adding the engine.

3. Identify the Area Item ID

With the form open in Runtime, use the console script in Grid Discovery. Copy the ID of the target ListView, not the SmartObject or View Definition ID.

4. Host the files

Create a custom folder under the K2 Styles path or use a separate same-origin IIS virtual directory. Do not overwrite native K2 resources. Back up custom files before K2 upgrades and replicate them across web nodes if applicable.

/Runtime/Runtime/styles/K2AdvancedGrid/
  engine/k2ag.engine.js
  config/purchase-orders.config.js
Download engine ↓Download configuration ↓

5. Set the Area Item ID

Open the downloaded configuration file and replace REPLACE_WITH_YOUR_AREAITEMID with your actual grid identifier. Open both hosted JavaScript URLs in the browser and verify that they return JavaScript, not a login page. See First Configuration for the complete template.

Important — required configuration change

Replace REPLACE_WITH_YOUR_AREAITEMID with the actual Area Item ID of your own ListView before using this example. See Grid Discovery. Without a matching ID the engine cannot target your ListView.

6. Add and configure a Data Label

Return to K2 Designer and edit the SmartForm containing the target ListView. Drag a Data Label control onto the form (not into a ListView row). Name it K2AG_Loader_DataLabel, enable the Literal property, disable Visible (tested with Fully External Deployment to avoid an empty row), and leave its data source unbound. Create an Expression for the control containing the complete loader script. One loader per form can serve multiple ListViews.

Designer screenshots will be added after capture; property names may vary by version.

7. Add the loader

Paste the complete loader below into the Data Label Expression. Adjust the base path to match your IIS folder. Do not also run an embedded engine. If using a different configuration filename, change the loader accordingly.

Download loader ↓
<script>(function(){var base='/Runtime/Runtime/styles/K2AdvancedGrid/',configVersion='0.2.2',engineVersion='1.0.0-beta.1.0-author2';if(window.K2AGExternalLoading||window.K2GridFiltersV2){console.warn('[K2AG] Existing loader or engine detected. Use only one deployment per form.');return;}window.K2AGExternalLoading=true;function load(url){return new Promise(function(resolve,reject){var s=document.createElement('script');s.src=url;s.onload=resolve;s.onerror=function(){reject(new Error('Failed to load '+url));};document.head.appendChild(s);});}load(base+'config/purchase-orders.config.js?v='+encodeURIComponent(configVersion)).then(function(){if(!window.K2AdvancedGridsConfig)throw new Error('Configuration missing');return load(base+'engine/k2ag.engine.js?v='+encodeURIComponent(engineVersion));}).then(function(){if(!window.K2AdvancedGrids||!window.K2AdvancedGrids.instance)throw new Error('Engine initialization failed');console.info('[K2AG] External deployment ready',window.K2AdvancedGrids.version);}).catch(function(e){console.error('[K2AG] External deployment failed',e);}).finally(function(){window.K2AGExternalLoading=false;});})();</script>

8. Save, run and verify

Save the Expression and SmartForm, then open the form in Runtime. Confirm that filter icons appear in column headers and check the browser Console for initialization messages.

console.log(K2AdvancedGrids.version);
console.table(K2AdvancedGrids.instance.inspect());

Expected: external deployment ready and one grid for the demo. Update configVersion whenever the config file changes, and engineVersion whenever the engine file changes. These query strings bypass cached URLs where the cache respects query strings. If they do not, use versioned filenames. Reopen the form and verify requests in Network. Saved preferences may override configured settings; reset them if appropriate. Restore the original Expression for rollback; this rollback test is still pending.

Enlarged screenshot