I need to add suggestions in adaptive card to be rendered on MS Teams.I have the list of suggestions from backend which i need to display as action buttons and when user clicks on any of the suggestion button the text needs to be displayed back as user message.
I tried using for each loop to iterate through list of suggestions but only the last suggestion comes up as an action button.How to display all suggestions as action buttons and display the text selected as user message?
"messages": [
{
"suggestion": [
"Good",
"Great",
" what can genie do for me."
],
"user_msg": "Hello, How are you?"
}
]
c#:
var list = row["suggestion"];
foreach (var li in list)
{
card.Actions = new List<AdaptiveAction>()
{
new AdaptiveSubmitAction
{
Title = li.ToString(),
DataJson = "{ \"Type\": \"book-user-meeting\" }",
}
};
}
the problem is that you're completely recreating the card.Actions property every single time inside the "for" loop. Your code should look something like this:
foreach (var li in list)
{
card.Actions.Add(
new AdaptiveSubmitAction
{
Title = li.ToString(),
DataJson = "{ \"Type\": \"book-user-meeting\" }",
}
);
}
Related
I want to use the same logic when I press the APPLY button but with the ENTER key.
How do I do that?
filterParams: {
closeOnApply:true,
buttons: ['reset', 'apply'],
values: parentCampaignAndNodes.PaymentGroups
},
As you might have found out by now, you can remove the Apply button (by setting filterParams: { buttons: [] } in your column definitions) and then values are submitted onchange.
The solution you ask for is indeed still not available through the AgGrid API. I do have a workaround, but beware it uses direct DOM bindings which is not recommended when working with React.
const applyFilterOnEnter: AgGridReactProps['onFilterOpened'] = ev => {
const inputElem = ev.eGui.querySelector('.ag-filter-body .ag-input-field');
const applyButtonElem = ev.eGui.querySelector('.ag-filter-apply-panel button[ref=applyFilterButton]');
if (inputElem && applyButtonElem) {
inputElem.addEventListener('keydown', keyEv => {
if ((keyEv as KeyboardEvent).key === 'Enter') {
(applyButtonElem as HTMLButtonElement).click();
}
});
}
};
return <AgGridReact
onFilterOpened={applyFilterOnEnter}
/>
There's a change to the tab name when I receive a notification on social networking sites.
It'll change from Website to 3 Notifications | Website
I'm curious about ways on Firefox I can prevent that sort of change.
Is it possible to filter out certain words from tab names?
You unfortunately cannot prevent tabs from updating the title in any modern browser. The only solution that I've seen, although not ideal, is to use a script to record the initial title of the page and keep the tab updated with that saved value. You can use a greasemonkey script for such a task:
var script = document.createElement("script");
script.textContent = "(" + t.toString() + ")()";
document.body.appendChild(script);
var title = document.title;
var updateTitle = function ()
{
document.title = title;
};
window.setInterval(updateTitle, 0);
The title is usually changed by assigning a new value to the document.title. You can freeze its value after the page is loaded with this user script:
// ==UserScript==
// #name Freeze title page
// #match *://*/*
// #run-at document-idle
// ==/UserScript==
const unsafeDocument = document.wrappedJSObject || document;
let title;
try {
title = unsafeDocument.head.getElementsByTagName('title')[0].innerText;
} catch { }
if (!title) {
title = unsafeDocument.title;
}
Object.defineProperty(unsafeDocument, 'title', {
get() {
return title;
},
set() { },
});
To avoid race condition with other scripts which might change document.title the title is read from <title> tag.
Note that this solution won't work if the title of the page is set to something like 3 Notifications | Website with the <title> element and not via scripts. In such case I have no idea how to do what you want in a generic way. You can hovewer force a manually-defined title on a per URL basis.
I've looked all over for help on this, which should be extremely easy, but I can't find exactly what I need. Here is my jsFiddle, which contains a super basic Kendo grid. I just want to get all data for the row that is currently selected (using a column of radio buttons) when the button is clicked.
http://jsfiddle.net/HTXua/412/
I know that when a row is selected, it is altering a property in the css class. Therefore, the row that I am trying to retrieve is going to have the property:
.detailGridRowSelector:checked
I have managed to implement the first row using checkboxes (instead of radio buttons) and count how many are checked, but I can't access the data for some reason!
var dataSource = {
data: [
{
"first": "Adam",
"last": "Paul"},
{
"first": "Shannon",
"last": "Harris"},
{
"first": "Frank",
"last": "Rolinson"},
]
};
var columns = [
{
template:'<input type="radio" class="detailGridRowSelector" title="Select Lines" name="radioLineSelector" />', width: 20
},
{
field: "first",
title: "First Name",
width: "90px"},
{
field: "last",
title: "Last Name",
width: "90px"},
];
$("#grid1").kendoGrid({
dataSource: dataSource,
columns: columns,
});
$("#getInfoButton").bind("click", function () {
var lineData ="line data would be set here";
//I know the selected row has the property: .detailGridRowSelector:checked
alert(lineData);
});
You should do:
// Get a reference to the grid
var grid = $("#grid1").data("kendoGrid");
// Get checked row by getting the input and then the row containing the input
var row = $("input:checked", grid.tbody).closest("tr");
// Get the item
var item = grid.dataItem(row);
// Format and display item
alert (JSON.stringify(item));
Your JSFiddle modified here: http://jsfiddle.net/OnaBai/HTXua/414/
SOLVED
Turns out I was making this way too hard on myself. I just learned that Kendo has a feature built in that handles this for you, so instead of using a column of radio buttons, I deleted it and implemented the
selectable: 'row'
feature. Then I just got it using
var grid = $("#grid1").data("kendoGrid");
var row = grid.select();
var data = grid.dataItem(row);
alert(data.first);
I have a dropdownlist of car brands:
#Html.DropDownListFor(
model => model.Brand,
new SelectList(
new List<Object>{
new { value = "Opel" , text = "Opel" },
new { value = "Lada" , text = "Lada" },
new { value = "BMW" , text = "BMW"}
},
"value",
"text"
As you can see, i was too lazy for making any classes, and thies code at the View.
How can i make a second dropdownlist: with car models ? I mean that user selects "Opel" and then can select "Corsa" or "Vectra" but not "X6" or "2110" ?
Looking for the most simple way to do it.
You want to make a cascading dropdown, probably using ajax.
This tutorial was almost made perfectly for you (car themed)
http://stephenwalther.com/archive/2008/09/07/asp-net-mvc-tip-41-creating-cascading-dropdown-lists-with-ajax.aspx
Below is the Javascript code used.
google.load("elements", "1", {packages : ["newsshow"]});
function loadNews(newsQuery)
{
//Load the news feed according to the topic selected
var options =
{
"format": "300x250",
"queryList" :
[
{
"title" : newsQuery,
"q" : newsQuery
}
]
}
var content = document.getElementById('content');
var newsShow = new google.elements.NewsShow(content, options);
}
The newsAddress value is a text box value entered by user. And based on the textbox value, the div element 'content' gets updated with a new element.
My problem is, every-time when I enter a value in text box (newsAddress), a news item in 'content' element is getting inserted one below the other. My requirement is to update the same news element based on the new search criteria.
How can this be done?