I've embeded the following server side code within <script> tag.
<% Dim dataTable As DataTable = cTab.getTabs(Session("UserID"))
If (dataTable.Rows.Count > 0) Then
For i As Int16 = 0 To dataTable.Rows.Count%>
{
contentEl: 'tab'+'<%dataTable.Rows(0)("TabID").ToString()%>',
title: '<%dataTable.Rows(0)("TabName").ToString()%>',
closable: false,
autoScroll: true
},
<% Next
End If %>
But it is not returning the desired results due to syntax problems. How can I write it correctly?
You've only given us a portion of the entire javascript, so we can't analyze what the surrounding script looks like in order to look for syntax issues. The snippet you've given will just start with an opening curly brace, which is not valid just standing by itself. What's preceeding it?
Besides that, if you want to output a string to the script, you need to do it using Response.Write or using the <%= %> shortcut. So for one, you need to do:
contentEl: 'tab'+'<%= dataTable.Rows(0)("TabID").ToString() %>',
title: '<%= dataTable.Rows(0)("TabName").ToString() %>',
(Notice the = signs).
Without seeing the surrounding code....
Looking at the loop each item is generated with a trailing comma (,) this means that there will be an extra comma at the end which is not valid is some browsers.
Invalid Example
var myObjArr = [
{
contentEl: 'tab'+'123',
title: 'name123',
closable: false,
autoScroll: true
},
{
contentEl: 'tab'+'456',
title: 'name456',
closable: false,
autoScroll: true
},
];
Valid Example
var myObjArr = [
{
contentEl: 'tab'+'123',
title: 'name123',
closable: false,
autoScroll: true
},
{
contentEl: 'tab'+'456',
title: 'name456',
closable: false,
autoScroll: true
}
];
Note the second sample has no extra comma (,).
Assuming your loop is working you probably don't want to have the same value every time. I think you might want to use i instead of 0. That is just a wild guess though since I really can't tell if the loop should work or not.
contentEl: 'tab'+'<%= dataTable.Rows(i)("TabID").ToString()%>',
Related
I've started building a form in react-jsonschema-form and i'm having a lot of difficulty changing it visually.
The form is an array and it has a button to add and remove a set of input boxes.
I've build it as a component in a test project which has no css applied to it so far.
The form will render as a tiny box where there is no room for the buttons (they are cut of as shown below in images).
a single element
a second element
How its supposed to look on react-jsonschema-form playground
A key difference between my array and the sample array is that i'm having two text input elements per array element. I dont know if this could cause it.
I do need to have two input values as its a group of data that is related, and both is required.
This is my code:
//json schema
const schema = {
type: "object",
properties: {
listOfNumbers: {
title: "opret ledig nummerserie",
type: "array",
required: ["nr_fra", "nr_til"],
items: {
properties: {
nr_fra: {
type: "string",
pattern: "^\\d*$",
minLength: 8,
maxLength: 8,
},
nr_til: {
type: "string",
pattern: "^\\d*$",
minLength: 8,
maxLength: 8,
},
},
},
},
},
};
//uiSchema
const uiSchema = {
listOfNumbers: {
"ui:options": {
orderable: false,
},
items: {
//nr_fra: { "ui:options": { label: false } },
//nr_til: { "ui:options": { label: false } },
},
},
}
I'm applying no css to the below form.
// Form
<Form
schema={schema}
uiSchema={uiSchema}
formData={this.state.formData}
onSubmit={(formOutput) => this.handleSubmit(formOutput)}
transformErrors={transformErrors}
/>
I've spent a day and a half on trying to strongarm this, but i could really use some help on how to proceed.
It seems it was css inputs that was needed to solve this.
The below will expand the elements to their proper size/form.
Posting this here for posterity, as this is not accurately documented.
<div className="col-md-offset-3 col-md-6">
<Form schema={schema}
uiSchema={uiSchema}>
</Form>
</div>
Telegram has a method for changing the image, it accepts InputMedia:
{
type: "photo",
media: IMAGE,
caption: TEXT,
parse_mode: "Markdown",
}
So, formatting doesn't work, even though I specified parse_mode.
My code
ctx.editMessageMedia({
type: "photo",
media: IMAGE,
caption: TEXT,
parse_mode: "Markdown",
}, message_id)
This seems correct to me. Since you're using Telegraf, given the context you can also do ctx.replyWithPhoto(...) or bot.telegram.sendPhoto(...).
Given the following example:
bot.command('photo', ctx => {
ctx.replyWithPhoto(
{
source: fs.createReadStream('img.jpg')
},
{
caption: 'Some *really* _nice_ __images__',
parse_mode: 'MarkdownV2'
}
).catch(err => console.log(err))
})
... when I say /photo, it produces the following result:
I am working with ASP.NET MVC 3. I have the following configuration for the grid:
grid.jqGrid({
data: pages,
datatype: 'json',
emptyrecords: 'No hay proyectos cargados',
colNames: ["Código", "Descripción", "Rev", "Cliente", "Tipo"],
colModel: [
{ name: 'Codigo', index: 'Codigo', width: 100 },
{ name: 'Descripcion', index: 'Descripcion asc, Descripcion', width: 200 },
{ name: 'Rev', index: 'Rev', width: 100, align: "right" },
{ name: 'Cliente', index: 'Cliente', width: 200, align: "right" },
{ name: 'Tipo', index: 'Tipo', width: 200, align: "right" }
],
rowNum: 10,
pager: '#dPager',
sortname: 'Codigo',
viewrecords: true,
sortorder: "desc",
beforeRequest: function() {
if (pages.length === 0) {
grid[0].p.page = 0;
}
},
height: 'auto',
});
The column names "Código" and "Descripción" display a weird symbol (a black diamond with a white question mark inside of it) instead of the "ó" characters.
For your information:
There are other "ó" characters in the View that are rendered, which makes me believe it has nothing to do with the page's encoding (FYI, the DOCTYPE tag is the standard that appears in the _Layout.cshtml).
jqGrid itself does render the special "ó" character in other controls, so long they appear in grid.locale-es.js. So, for instance, the literal for "Page X of Y" is "Página X de Y", and if I change it for "óóóóóóóóó X de Y" it renders it properly.
The same problem happens if I change, for instance, the emptyrecords entry with "óóóóóó".
Any ideas why does this happen?
This could happen because you have placed this script in a javascript file which doesn't have the correct encoding to match with your site.
So for example if your site is UTF-8, make sure that you have saved the .js file with UTF-8 with BOM.
Open the .js file in Visual Studio and choose File->Save As
Click on the down arrow next to the Save button
Select Save with Encoding ...
From the drop down list select Unicode (UTF-8 with signature) - Codepage 65001:
I have the following code, which generates a basic layout for my app:
tabpanel = new Ext.TabPanel({
fullscreen: false,
ui : 'dark',
sortable : false,
tabBarDock: 'bottom',
cardSwitchAnimation: 'flip',
items: [{
title: 'Tab 1',
html : '1',
cls : 'card1',
icon : 'tab1'
}]
});
lists.views.Viewport = Ext.extend(Ext.Panel,{
fullscreen: true,
layout: 'fit',
dockedItems: [{
xtype: 'toolbar',
dock: "top",
title: 'title'
}],
items: [tabpanel],
initComponent: function() {
this.tabpanel.add(new lists.views.ItemLists());
lists.views.Viewport.superclass.initComponent.apply(this, arguments);
},
});
This doesn't work, probably due to the fact that the TabPanel that is inside the Viewport Panel cannot be pointed to like this. I've searched through the sencha documentation but I can't find how to add the
new lists.views.ItemLists()
to the tabpanel, which in turn is inside the
lists.views.Viewport
Also, there will be other stuff I want to declare before my viewport (or even after it) that I want to add to specific other panels I might add later. What is the best way to achieve this?
Any ideas on how to do this?
Thanks!
If you take the this. off the reference to the tabpanel in the Viewport's initComponent method then it should work because the tabpanel variable is global.
Alternatively, you can access the Viewport's items via the items property, for example,
initComponent: function(){
this.items.get(0).add(new lists.views.ItemLists());
lists.views.Viewport.superclass.initComponent.apply(this, arguments);
}
Hope this helps
Stuart
I’m trying to create a Datagrid with editable cells.
As I am using dijits for the editable cells I try to set constraints within the “widgetProps” property of the layout, like this:
widgetProps: {
required: true,
constraints: {
min: 0,
max: 100,
places: '0,2'
}
}
Here required: true works as expected, whereas the constraints property is not working at all.
An example here: http://jsfiddle.net/LjVmJ/ where I've tried to use constraints both in a NumberTextBox and a DateTextBox.
Bug in Dojo or am I missing something?
From Oliver on the dojo mailinglist:
It should be "constraint", and it should be put outside "widgetProps".
Which solves the problem.
I found a ‘dirty’ solution to this issue:
First declare my own NumberTextBox with the required constraints:
dojo.declare(
"my.custom.PercentageNumberTextBox",
[dijit.form.NumberTextBox],
{
postCreate: function(){
this.inherited(arguments);
this.set('constraints', {min:0,max:100, places:'0,2'});
}
});
Then I’m using it as the widgetClass in the grid structure:
{
field: 'employmentPercentage',
name: 'Employment %',
type: dojox.grid.cells._Widget,
widgetProps: { required: true },
widgetClass: my.custom.PercentageNumberTextBox,
editable: true,
width: '150px'
}
This is a workaround for now (full example here: http://jsfiddle.net/LjVmJ/2/),