Excel Custom Function is not shown - excel

I am creating an Excel custom function inside an office add-in. My starting point was Visual Studio 2017 scaffolding.
In my manifest I have
<FunctionFile resid="Contoso.DesktopFunctionFile.Url" />
where
<bt:Url id="Contoso.DesktopFunctionFile.Url" th:DefaultValue="${baseUrl+'/Functions/FunctionFile.html'}" />
The FunctionFile.html is the file generated by Visual Studio
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<title></title>
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="https://appsforoffice.microsoft.com/lib/1/hosted/office.js" type="text/javascript"></script>
<script src="FunctionFile.js" type="text/javascript"></script>
</head>
<body>
<!-- NOTA: il corpo รจ intenzionalmente vuoto. Dal momento che viene richiamato tramite un pulsante, non esiste interfaccia utente di cui eseguire il rendering. -->
</body>
</html>
And in FunctionFile.js I put
(function () {
Office.initialize = function (reason) {
function sum(var1, var2){
return var1+var2;
}
};
})();
Excel Ignores function "sum" but other features of my plugin work.
Is FunctionFile.js inside Office.initialize the correct place to define custom functions?
Where can I set the namespace for my functions?

After some test I found this workaround
My manifest file look like this
<AllFormFactors>
<ExtensionPoint xsi:type="CustomFunctions">
<Script>
<SourceLocation resid="Functions.Script.Url"/>
</Script>
<Page>
<SourceLocation resid="Functions.Page.Url"/>
</Page>
<Metadata>
<SourceLocation resid="Functions.Metadata.Url"/>
</Metadata>
<Namespace resid="Functions.Namespace"/>
</ExtensionPoint>
</AllFormFactors>
AllFormFacotrs goes between
<Host xsi:type="Workbook">
...
</Host>
functionFile.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta http-equiv="Expires" content="0" />
<title></title>
<script src="https://appsforoffice.microsoft.com/lib/1.1/hosted/custom-functions-runtime.js" type="text/javascript"></script>
<script src="functionFile.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>
funciton.json is something like
{
"functions": [
{
"description": "Calculates the volume of a sphere.",
"id": "SPHEREVOLUME",
"name": "SPHEREVOLUME",
"parameters": [
{
"name": "radius",
"type": "number"
}
],
"result": {}
}
]
}
And at last the real code goes ender functionFile.js
var funcs = {};
funcs['SPHEREVOLUME'] = function(raggio){
return 444*raggio;
};
//ugly code
! function(e) {
var t = {};
function n(o) {
if (t[o])
return t[o].exports;
var r = t[o] = { i: o, l: !1, exports: {} };
return e[o].call(r.exports, r, r.exports, n), r.l = !0, r.exports
}
n.m = e, n.c = t, n.d = function(e, t, o) { n.o(e, t) || Object.defineProperty(e, t, { enumerable: !0, get: o }) }, n.r = function(e) { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(e, "__esModule", { value: !0 }) }, n.t = function(e, t) {
if (1 & t && (e = n(e)), 8 & t) return e;
if (4 & t && "object" == typeof e && e && e.__esModule) return e;
var o = Object.create(null);
if (n.r(o), Object.defineProperty(o, "default", { enumerable: !0, value: e }), 2 & t && "string" != typeof e)
for (var r in e) n.d(o, r, function(t) { return e[t] }.bind(null, r));
return o
}, n.n = function(e) { var t = e && e.__esModule ? function() { return e.default } : function() { return e }; return n.d(t, "a", t), t }, n.o = function(e, t) { return Object.prototype.hasOwnProperty.call(e, t) }, n.p = "", n(n.s = 1)
}(
{
1: function(e, t) {
Object.entries(funcs).forEach(([key, value]) => {
CustomFunctions.associate(''+key, value);
});
//CustomFunctions.associate("SPHEREVOLUME", funcs['SPHEREVOLUME']);
}
}
);
What "ugly code" is a piece of code generated by yo I cannot clean up.
In this way the function
is visible.

Related

WKWebView addEventListener not receiving Calendly events

I'm trying to use Calendly within a WKWebView and receive an event when the user has created an appointment. The app is successfully receiving message events, however Calendly events are not appearing.
Here's the code:
import UIKit
import WebKit
class ViewController: UIViewController, WKScriptMessageHandler {
var webView: WKWebView!
var count = 0
var html = """
<html>
<head>
<meta name='viewport' content='width=device-width' />
</head>
<!-- Calendly inline widget begin -->
<div class="calendly-inline-widget" data-auto-load="false">
<script type="text/javascript" src="https://assets.calendly.com/assets/external/widget.js"></script>
<script>
Calendly.initInlineWidget({
url: 'https://calendly.com/XXX',
prefill: {
name: "John Doe",
email: "john#joe2.com",
customAnswers: {
a1: "yes"
}
}
});
</script>
</div>
<!-- Calendly inline widget end -->
</html>
"""
override func viewDidLoad() {
let config = WKWebViewConfiguration()
let js =
"""
function isCalendlyEvent(e) {
return e.data.event &&
e.data.event.indexOf('calendly') === 0;
};
window.addEventListener(
'message',
function(e) {
if (isCalendlyEvent(e)) {
console.log("!!!!!!!!!!!!!!!!!!!!!!!!!!!");
console.log(e.data);
}
}
);
function isCalendlyEvent(e) {
console.log('testing' + e.name);
return e.data.event &&
e.data.event.indexOf('calendly') === 0;
};
window.addEventListener('message', function(e){
console.log('In listener. Event.type: ' + event.type +
' e.data.event: ' + e.data.event + ' event: ' + JSON.stringify(e.data));
if (isCalendlyEvent(e)) {
console.log('calendly event!!!!');
window.webkit.messageHandlers.clickListener.postMessage('Calendly:' + e.data);
} else {
window.webkit.messageHandlers.clickListener.postMessage('Other:' + e.data);
}
});
"""
let script = WKUserScript(source: js, injectionTime: .atDocumentEnd, forMainFrameOnly: false)
config.userContentController.addUserScript(script)
config.userContentController.add(self, name: "clickListener")
webView = WKWebView(frame: view.bounds, configuration: config)
view.addSubview(webView!)
self.webView.loadHTMLString(self.html, baseURL: nil)
}
func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
count = count + 1
print("Msg \(count): \(message.body) ")
}
}
The calendly message is only sent when the url includes the embed_domain query parameter. When Calendly.initInlineWidget is called inside of WKWebView the embed_domain query parameter is set to undefined.
To resolve this issue, you can update the url to include an embed_domain parameter:
Calendly.initInlineWidget({
url: 'https://calendly.com/XXX?embed_domain=example',
prefill: {
name: "John Doe",
email: "john#joe2.com",
customAnswers: {
a1: "yes"
}
}
});

Showing dialog by Dialog API disables cell editing

In my Excel Add-In, I use the Dialog API to show messages to the user. The dialog is shown and closed without any problem or error thrown.
When the dialog is closed, the user cannot edit cells in the sheet by a simple click in the cell and writing.
If the user double click some cell, this functionality is back again (for all cells).
Here is the code controlling the dialog:
var app = (function (app) {
var dialog;
// Show dialog
app.showNotification = function (header, text) {
if (Office.context.requirements.isSetSupported('DialogApi', 1.1)) {
var dialogUrl = window.location.href.substring(0,
window.location.href.lastIndexOf('/') + 1) +
"AppMessage.html?msg=" + text + "&title=" + header;
Office.context.ui.displayDialogAsync(dialogUrl, {
height: 20,
width: 20,
displayInIframe: true
},
function (asyncResult) {
dialog = asyncResult.value;
dialog.addEventHandler(Office.EventType.DialogMessageReceived,
processMessage);
});
}
};
function processMessage(arg) {
if (arg.message == "close")
dialog.close();
}
return app;
})(app || {});
and the dialog code
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script src="https://appsforoffice.microsoft.com/lib/1/hosted/Office.js" type="text/javascript"></script>
<link rel="stylesheet" href="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-js/1.4.0/css/fabric.min.css">
<link rel="stylesheet" href="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-js/1.4.0/css/fabric.components.min.css">
<script src="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-js/1.4.0/js/fabric.min.js"></script>
</head>
<body>
<span class="ms-font-xl ms-fontWeight-semibold" id="titleMain"></span>
<p class="ms-font-m" id="body"></p>
<button class="ms-Button ms-Button--primary" style="position:fixed;bottom:10px;right:10px;" onclick="closeDialog();">
<span class="ms-Button-label">OK</span>
</button>
<script src="appMessage.js"></script>
</body>
</html>
and here is the appMessage.js content
var urlParams;
Office.initialize = function () {};
//avoiding the usage of jquery in this small page
window.$ = function (selector) {
return document.querySelector(selector);
};
function closeDialog() {
Office.context.ui.messageParent("close");
}
(window.onpopstate = function () {
var match,
pl = /\+/g, // Regex for replacing addition symbol with a space
search = /([^&=]+)=?([^&]*)/g,
decode = function (s) {
return decodeURIComponent(s.replace(pl, " "));
},
query = window.location.search.substring(1);
urlParams = {};
while (match = search.exec(query))
urlParams[decode(match[1])] = decode(match[2]);
$("#titleMain").innerHTML = urlParams["title"];
$("#body").innerHTML = urlParams["msg"];
})();
What can be wrong?
Thanks

PhoneGap 3.3.0 / Cordova iOS 7 Audio Record Permission

I am new to PhoneGap / Cordova development. Recently there was an update on iOS, and it requires users to grant permission to applications before they can use the microphone.
I had tried to update the "package" - Media and Media Capture, but it still not working.
I've also tried a plugin called cordova-phonegap-audio-encode, but it isn't working too.
The following are my code:
Record.html (This is a page / interface for users to interact and trigger the permission/recording audio)
<html>
<head>
<title>System</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="../js/cordova-2.3.0.js"></script>
<script src="../js/config.js"></script>
<script src="../js/languages.js"></script>
<script src="beJS.js"></script>
<link rel="stylesheet" href="../js/jquery.mobile-1.3.0.min.css" />
<script src="../js/jquery-1.8.2.min.js"></script>
<script src="../js/jquery.mobile-1.3.0.min.js"></script>
<script scr="../js/RecordPermission.js"></script>
</head>
<body >
<div data-role="page" id="beRecordPage">
<div data-role="header" data-theme="c" data-position="fixed">
<a href="index.html" id="btnMenu" target="_self" data-icon="home" data-ajax='false'></a>
<h1 id="be_header_record"></h1>
</div><!-- /header -->
<div data-role="content" >
<div class="content-primary" id='programContent' >
<label for="length" id="be_reocrd_lbl_scriptName"></label>
<input type="text" name='scriptName' id="scriptName" value="" data-clear-btn="true" maxlength="30"/>
<hr/>
<div data-role="controlgroup" >
<button type="button" data-theme="c" id="be_reocrd_btn_record" onclick='record();'></button>
<button type="button" data-theme="c" id="be_reocrd_btn_play" onclick='playRecord();'></button>
<button type="button" data-theme="c" id="be_reocrd_btn_delete" onclick='deleteRecord();'></button>
</div>
<div><!-- /content-primary -->
<div><!-- /content -->
</div><!-- /page -->
<script>
var isRecorded = false;
var isRecording = false;
var isPlaying = false;
var recordResult =false;
var lastSrc = "";
var src = "";
var mediaRec;
function playRecord(){
if(isRecorded && !isRecording){
if(isPlaying){
stopPlaying();
}else{
mediaRec = new Media(lastSrc, stopPlaying,null);
mediaRec.play();
isPlaying = true;
$('#be_reocrd_btn_record').button('disable');
$('#be_reocrd_btn_delete').button('disable');
$('#be_reocrd_btn_play').text(language[langCode].be_reocrd_btn_stop);
$('#be_reocrd_btn_play').button('refresh');
}
}else{
alert(language[langCode].be_reocrd_msg_pleaseRecord);
}
}
function deleteRecord(){
if(isRecorded && !isRecording && !isPlaying){
var confirmation=confirm(language[langCode].be_reocrd_msg_deleteConfirmation);
if(confirmation){
performDeleteRecord()
}
}else{
alert(language[langCode].be_reocrd_msg_deleteError);
}
}
var fileRoot;
function onFileSystemSuccess(fileSystem) {
fileRoot = fileSystem.root;
fileRoot.getFile(lastSrc, {create: false}, onGetFileSuccess, onError);
}
function onGetFileSuccess(entry){
entry.remove(function() {
var idx = --localStorage.SYS_RECORDFILEINDEX;
localStorage.removeItem("SYS_RECORD_NAME"+idx);
localStorage.removeItem("SYS_RECORD_PATH"+idx);
alert(language[langCode].be_reocrd_msg_deleteSuccessful);
}, onError
);
}
function onError() {
alert(language[langCode].be_reocrd_msg_deleteFailure);
}
function onRequestFileSystemSuccess(fileSystem) {
src = fileSystem.root.fullPath + '/' + src;
fileSystem.root.getFile(src, {create: true}, function() {
mediaRec = new Media(src, successRecord,failRecord);
mediaRec.startRecord();
}, function(err) {
alert(err.message);
}
);
/*
var entry=fileSystem.root;
entry.getDirectory(recordFileFolder, {create: true, exclusive: false}, onGetDirectorySuccess, onGetDirectoryFail);
*/
}
function onGetDirectorySuccess(dir) {
alert("Created dir "+dir.name);
mediaRec = new Media(src, successRecord,failRecord);
mediaRec.startRecord();
}
function onGetDirectoryFail(error) {
alert("Error creating directory "+error.code);
}
function performDeleteRecord(){
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess, onError);
return true;
}
function successRecord(){
isRecorded = true;
recordResult = true;
lastSrc = src;
var idx = localStorage.SYS_RECORDFILEINDEX;
localStorage["SYS_RECORD_NAME"+idx] = $('#scriptName').attr('value');
localStorage["SYS_RECORD_PATH"+idx] = lastSrc;
localStorage.SYS_RECORDFILEINDEX++;
}
function stopPlaying(){
if(mediaRec != null){
mediaRec.stop();
mediaRec = null;
}
isPlaying = false;
$('#be_reocrd_btn_record').button('enable');
$('#be_reocrd_btn_delete').button('enable');
$('#be_reocrd_btn_play').text(language[langCode].be_reocrd_btn_play);
$('#be_reocrd_btn_play').button('refresh');
}
function failRecord(err){
alert(err.message);
alert(language[langCode].be_reocrd_msg_recordFailure);
$('#be_reocrd_btn_record').text(language[langCode].be_reocrd_btn_start);
recordResult = false;
}
function performRecord(){
var result = false;
src = recordFileFolder+new Date().getTime()+".wav";
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onRequestFileSystemSuccess, null);
// mediaRec = new Media(src, successRecord,failRecord);
// mediaRec.startRecord();
}
function record(){
if($('#scriptName').attr('value') == ''){
alert(language[langCode].be_reocrd_msg_pleaseInputName);
return;
}
if(!isPlaying){
if(!isRecording){
$('#be_reocrd_btn_record').text(language[langCode].be_reocrd_btn_stop);
$('#be_reocrd_btn_play').button('disable');
$('#be_reocrd_btn_delete').button('disable');
isRecording = true;
performRecord();
}else{
mediaRec.stopRecord();
isRecording = false;
$('#be_reocrd_btn_record').text(language[langCode].be_reocrd_btn_start);
$('#be_reocrd_btn_play').button('enable');
$('#be_reocrd_btn_delete').button('enable');
}
$('#be_reocrd_btn_record').button('refresh');
}else{
alert(language[langCode].be_reocrd_msg_pleaseStopPlaying);
}
}
$('#beRecordPage').live('pagecreate',function(event){
checkLoggedIn();
$('#be_header_record').text(language[langCode].be_header_record);
$('#btnMenu').text(language[langCode].menu);
$('#be_reocrd_lbl_scriptName').text(language[langCode].be_reocrd_lbl_scriptName);
$('#be_reocrd_btn_record').text(language[langCode].be_reocrd_btn_start);
$('#be_reocrd_btn_play').text(language[langCode].be_reocrd_btn_play);
$('#be_reocrd_btn_delete').text(language[langCode].be_reocrd_btn_delete);
});
</script>
</body>
</html>
This is the RecordPermission.js
window.recordPermission = function(params) {
cordova.exec(function(answer){
if (answer === "True") params.success(true);
else if (answer === "False") params.success(false);
else params.error('success called with "'+answer+'". Must be "True" or "False" strings');
}, params.error,"RecordPermission", "recordPermission");
};
The following is RecordPermission.m
#import "RecordPermission.h"
#implementation RecordPermission
#synthesize callbackId;
- (void)recordPermission:(CDVInvokedUrlCommand*)command
{
self.callbackId = command.callbackId;
// First check to see if we are in ios 7.
NSArray *vComp = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:#"."];
if ([[vComp objectAtIndex:0] intValue] < 7) {
// before iOS7 when this permission was not required or setable by the user
[self performSelectorOnMainThread:#selector(doSuccessCallback:) withObject:#"True" waitUntilDone:NO];
} else {
// run this in a try just in case
#try {
[[AVAudioSession sharedInstance] requestRecordPermission:^(BOOL granted) {
// cast this to a string bc I don't know if you can or how to pass a boolean back to javascript.
// This is converted back to a javascript boolean in RecordPermission.h.js file
NSString * grantedString = (granted) ? #"True" : #"False";
// talking back to javascript must be done in main thread.
[self performSelectorOnMainThread:#selector(doSuccessCallback:) withObject:grantedString waitUntilDone:NO];
}];
} #catch (id exception) {
NSLog(#"recordPermission try error");
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_JSON_EXCEPTION messageAsString:[exception reason]];
NSString* javaScript = [pluginResult toErrorCallbackString:command.callbackId];
[self writeJavascript:javaScript];
}
}
}
-(void) doSuccessCallback:(NSString*)granted {
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:granted];
NSString* javaScript = [pluginResult toSuccessCallbackString:self.callbackId];
[self writeJavascript:javaScript];
}
#end
This is the RecordPermission.h
#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>
#import <Cordova/CDV.h>
#interface RecordPermission : CDVPlugin{
NSString* callbackId;
}
#property (nonatomic, retain) NSString* callbackId;
- (void)recordPermission:(NSArray*)arguments ;
#end
So far I cannot trigger the permission and I checked "Settings" where the app does not appear at the "Microphone" page.
Please help! Thank you.

Can't autoclick icon link within a frame for a webpage VBA

I'm trying to write a vba code to autoclick icon link after logged in. I'm stuck with the vba code I wrote below and when I run the vba macro no responses. I believe the icon link is within a frame for a webpage. Please help thanks
I've tried right clicking on the icon link to check for the frame url address, and navigate to that webpage once logged in however it automatically redirects to another page which I don't want.
URL address (target webpage with the icon link): "https://trading.poems.com.hk/poems2/poems.asp?func=view"
Auto Redirected webpage: "https://trading.poems.com.hk/poems2/loginaction.asp"
The icon link html code:
<img src="images/Corner/EN/Company.png" border=0 title="Stock Analytics ">
My VBA code:
Sub open3()
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.navigate "https://trading.poems.com.hk/poems2/poems.asp?func=view"
Do Until ie.readyState = 4
DoEvents
Loop
For Each ele In ie.document.getElementsByTagName("a")
If InStr(ele.innerHTML, "images/Corner/EN/Company.png") > 0 Then
ele.Click
Exit For
End If
Next
End Sub
The frames of the webpage:
<html>
<head>
<title>Phillip Securities (HK)-?????? (?????????)</title>
<link rel="shortcut icon" href="images/phillip.ico">
<meta http-equiv="Content-Type" content="text/html; charset=big5"></head>
<frameset cols="*, 100%" border=0 frameborder=0 framespacing=0 marginheight=0 marginwidth=0>
<frame src="Poems2/BrowserChecking.asp" name="ChkBrowser">
<frame src="Poems2/Poems.asp" name="login" frameborder=0 framespacing=0 marginheight=0 marginwidth=0>
</frameset><noframes></noframes>
</html>
Parts of the HTML source code:
<!DOCTYPE html PUBLIC "-/W3C//DTD XHTML 1.0 Transtitional//EN"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5" />
<title>??????-?????????</title>
</head>
<link href="css/phillip.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" >document.domain="poems.com.hk"</script>
<script type="text/javascript" src="js/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/ddsmoothmenu_Execution_EN.css" />
<script type='text/javascript' src='js/ddsmoothmenu.js'></script>
<script type="text/javascript" src="js/font.js"></script>
<script type="text/javascript">
ddsmoothmenu.init({
mainmenuid: "smoothmenu1", //menu DIV id
orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
classname: 'ddsmoothmenu', //class added to menu's outer DIV
//customtheme: ["#1c5a80", "#18374a"],
contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})
</script>
<script type="text/javascript">
var myclose = false;
function ConfirmClose()
{
frameURL = (parent.DetailFrame.location.href).toUpperCase()
//alert(frameURL + "//// " + frameURL.indexOf("PPSHK.COM"))
if (frameURL.indexOf("PPSHK") > 0)
{
if (event.clientY < 0)
{
event.returnValue = '???????????, ?????????\n????!';
//setTimeout('myclose=false',10000);
//myclose=true;
}
}
}
function parentExists() {
return (parent.location == window.location) ? false : true;
}
if(!parentExists())
document.location = "../index2.htm"
function checkKeyCode(evt)
{
var evt = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if(event.keyCode==116)
{
location.reload(true);
return false
}
}
document.onkeydown=checkKeyCode;
</script>
<body onUnload="CloseAllPop()">
<script>
var EFuturePop
var StockPop
var USStockPop
var SGStockPop
var JPStockPop
var SAStockPop
var SOptionPop
var SNOptionPop
var StockGTCPop
var BullionPop
var FxBannerPop
var FoFuturePop
var ForexPop
var FoOptionsPop
var ForexResponse
var FoFutureResponse
var FoOptionsResponse
function CloseAllPop(){
if(EFuturePop != null){
EFuturePop.close()
}
if(StockPop != null){
StockPop.close()
}
if(USStockPop != null){
USStockPop.close()
}
if(SGStockPop != null){
SGStockPop.close()
}
if(JPStockPop != null){
JPStockPop.close()
}
if(SAStockPop != null){
SAStockPop.close()
}
if(SOptionPop != null){
SOptionPop.close()
}
if(SNOptionPop != null){
SNOptionPop.close()
}
if(StockGTCPop != null){
StockGTCPop.close()
}
if(BullionPop != null){
BullionPop.close()
}
// if(FxBannerPop != null){
// FxBannerPop.close()
// }
if(FoFuturePop != null){
FoFuturePop.close()
}
if(ForexPop != null){
ForexPop.close()
}
if (FoOptionsPop != null) {
FoOptionsPop.close()
}
}
function forexClose(ans){
ForexResponse = ans;
}
function foFutureClose(ans){
FoFutureResponse = ans;
}
function foOptionsClose(ans) {
FoOptionsResponse = ans;
}
function DisclaimerClose(type,ans){
if (type == "Forex"){
ForexResponse = ans;
}
else if (type == "FoFuture"){
FoFutureResponse = ans;
}
else if (type == "FoOptions") {
FoOptionsResponse = ans;
}
}
function changeDetailFrame(link) {
$('#DetailFrame').attr('src',link);
}
function CheckStockGTCPop(){
if(StockGTCPop != null){
parent.DetailFrame.location.href = "NoPopup/ZH/TradeStock_GTC.asp"
}
else{
StockGTCPop = window.open('StockDisclaimer_GTC.asp','HKStockGTC','scrollbars=yes,resizable=yes,status=no,left=0,top=0,width=1014,height=710,toolbar=0')
}
}
function CheckForexPop(){
if (ForexResponse=="A"){
if (ForexPop.closed) {
ForexPop = window.open('Forex/asp/menu/100kforex_fr.asp','Forex','scrollbars=yes,resizable=yes,status=no,left=0,top=0,width=1014,height=710,toolbar=0')
}
}
else{
ForexPop = window.open('ForexDisclaimer.asp','Forex','scrollbars=yes,resizable=yes,status=no,left=0,top=0,width=1014,height=710,toolbar=0')
}
}
function CheckFoFuturePop(){
if (FoFutureResponse=="A"){
if (FoFuturePop.closed){
FoFuturePop = window.open('FoFutures/EN/ftslingshot2b3/LiveMain_fr.asp?type=F', 'FoFuture', 'scrollbars=yes,resizable=yes,status=no,left=0,top=0,width=1014,height=710,toolbar=0')
}
}
else{
FoFuturePop = window.open('FoFutureDisclaimer.asp','FoFuture','scrollbars=yes,resizable=yes,status=no,left=0,top=0,width=1014,height=710,toolbar=0')
}
}
function CheckFoOptionsPop() {
if (FoOptionsResponse == "A") {
if (FoOptionsPop.closed) {
FoOptionsPop = window.open('FoFutures/EN/ftslingshot2b3/LiveMain_fr.asp?type=O', 'FoFuture', 'scrollbars=yes,resizable=yes,status=no,left=0,top=0,width=1014,height=710,toolbar=0')
}
}
else {
FoOptionsPop = window.open('FoOptionsDisclaimer.asp','FoOptions', 'scrollbars=yes,resizable=yes,status=no,left=0,top=0,width=1014,height=710,toolbar=0')
}
}
// function CheckFoFuturePop_FO(){
// FoFuturePop = window.open('FoFutures/EN/ftslingshot2b3/LiveMain_fr_FO.asp','FoFuture','scrollbars=yes,resizable=yes,status=no,left=0,top=0,width=1014,height=710,toolbar=0')
// }
function CheckFxBannerPop(){
if(FxBannerPop != null){
parent.DetailFrame.location.href = "Forex/asp/menu/100kforex_fr.asp"
}
else{
parent.DetailFrame.location.href = "Forex/asp/menu/100kforex_fr.asp"
FxBannerPop = window.open('Banner.htm','FxBanner','scrollbars=yes,resizable=yes,status=no,left=0,top=0,width=600,height=300,toolbar=0')
}
}
//document.body.onunload = CloseAllPop
</script>
<table width="985" border="0" align="center" cellpadding="0" cellspacing="0" id="maintable">
<tr>
<td width="10" background="images/bgsquareleft.jpg"></td>
<td bgcolor="#FFFFFF"><table width="940" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="64"><img src="POEMSBanner.gif" alt="Phillip's ON-LINE ELECTRONIC MART SYSTEM" height="54" border="0" /></td>
<td align="right" valign="bottom" class="style3">
<img src="images/Corner/EN/tradingcen.png" border=0 title="Trading Central">
<img src="images/Corner/EN/Company.png" border=0 title="Stock Analytics ">&>
Your URL "https://trading.poems.com.hk/poems2/poems.asp?func=view" returns HTML code for a frameset page with not a single tag.
Note that the Document element within the Browser object doesn't expand the underlying pages. You see the same here as you would in the browser using the "show source" function
Check the possibility of calling (one of) the framed page(s) directly

Need to get a field editable depending on a field content in EXT.NET. Get this.field.msgTarget is null or not an object error

I try to use your example to dynamically add/remove editor and get this error:
this.field.msgTarget is null or not an object error. I'm new to the ext.net - could somebody help me?
Thanks,
Jenny
this is my code:
EditExample.aspx:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="EditExample.aspx.cs" Inherits="myApp.EditExample" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%# Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
var setEditor = function (e) {
var column = e.grid.getColumnModel().columns[e.column],
ed = column.getCellEditor(e.row);
if (ed && (e.value != null || e.value != '')) {
ed.destroy();
}
else {
column.setEditor(new Ext.form.TextField());
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager runat="server" />
<ext:Store ID="extStore" runat="server" >
<Reader>
<ext:JsonReader>
<Fields>
<ext:RecordField Name = "Name" />
<ext:RecordField Name = "Code" ></ext:RecordField>
<ext:RecordField Name = "Description" ></ext:RecordField>
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
<div>
<ext:GridPanel ID="extGrd" runat="server" StripeRows="true" TrackMouseOver="true"
StoreID="extStore" Cls="x-grid-custom"
Height="250px" Layout="fit">
<ColumnModel ID="cmFC" runat="server">
<Columns>
<ext:Column ColumnID="Name" DataIndex="Name" Header="Name">
</ext:Column>
<ext:Column ColumnID="Code" DataIndex="Code" Header="Code">
</ext:Column>
<ext:Column ColumnID="Description" DataIndex="Description" Header="Description" Editable ="true" >
<Editor>
<ext:TextField ID="TextField1" runat="server"></ext:TextField>
</Editor>
</ext:Column>
</Columns>
</ColumnModel>
<Listeners>
<BeforeEdit Fn="setEditor" />
<Render Handler="this.getColumnModel().setEditable(0, true);" />
</Listeners>
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true" MoveEditorOnEnter="true"/>
</SelectionModel>
<LoadMask ShowMask="true" />
</ext:GridPanel>
</div>
</form>
</body>
</html>
EditExample.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace myApp
{
public class info
{
public string Name { get; set; }
public string Code { get; set; }
public string Description { get; set; }
}
public partial class EditExample : System.Web.UI.Page
{
protected void Page_Load( object sender, EventArgs e )
{
List<info> thisInfo = new List<info>();
thisInfo.Add( new info { Code = "1", Description = "one", Name = "one Name" } );
thisInfo.Add( new info { Code = "2", Description = "two", Name = "two Names" } );
thisInfo.Add( new info { Code = "3", Description = "three", Name = "three Names" } );
thisInfo.Add( new info { Code = "4", Description = "four", Name = "four Names" } );
thisInfo.Add( new info { Code = "5", Description = "five", Name = "five Names" } );
thisInfo.Add( new info { Code = "6", Description = "six", Name = "six Names" } );
this.extStore.DataSource = thisInfo;
this.extStore.DataBind();
}
}
EDIT:
I tried to make the field disabled and readonly.
It made the field appear disabled (greyed out), but readable.
var setEditor = function (e)
{
var column = e.grid.getColumnModel().columns[e.column],
ed = column.getCellEditor(e.row);
if (ed)
{
if (e.value != null && e.value != '')
{
ed.readOnly = true; ed.setDisabled(true);
}
else
{
ed.readOnly = false; ed.setDisabled(false);
}
}
}
You can just return false to before event.
var setEditor = function (e) {
var column = e.grid.getColumnModel().columns[e.column],
ed = column.getCellEditor(e.row);
if (ed && (e.value != '')) {
return false;
}
}

Resources