electron : In simple hello world app, not able to view the default menu bar - electron

I am new to electron and trying to run the simple hello world.
In that "Electron" app, its menu bar should show up as a normal application with generic options, such as edit, view, window, help. But I am not able to see it. My OS system is macOS High Sierra.
I simple hello world code I have taken from the following link.
https://www.tutorialspoint.com/electron/electron_hello_world.htm
https://www.youtube.com/watch?v=RL305ldfzm8&list=PLC3y8-rFHvwiCJD3WrAFUrIMkGVDE0uqW&index=2
Could any one help?

Adding this work for me
const { isMac } = electron;

The menu shown in the tutorial is for windows system. The default menu is shown if no menu is set using Menu.setApplicationMenu(menu). Sets menu as the application menu on macOS. On Windows and Linux, the menu will be set as each window's top menu.. If you want to show that default menu use the following.
Use the https://electronjs.org/docs/api/menu#menusetapplicationmenumenu link for reference
const { app, Menu } = require('electron')
const template = [
// { role: 'appMenu' }
...(process.platform === 'darwin' ? [{
label: app.getName(),
submenu: [
{ role: 'about' },
{ type: 'separator' },
{ role: 'services' },
{ type: 'separator' },
{ role: 'hide' },
{ role: 'hideothers' },
{ role: 'unhide' },
{ type: 'separator' },
{ role: 'quit' }
]
}] : []),
// { role: 'fileMenu' }
{
label: 'File',
submenu: [
isMac ? { role: 'close' } : { role: 'quit' }
]
},
// { role: 'editMenu' }
{
label: 'Edit',
submenu: [
{ role: 'undo' },
{ role: 'redo' },
{ type: 'separator' },
{ role: 'cut' },
{ role: 'copy' },
{ role: 'paste' },
...(isMac ? [
{ role: 'pasteAndMatchStyle' },
{ role: 'delete' },
{ role: 'selectAll' },
{ type: 'separator' },
{
label: 'Speech',
submenu: [
{ role: 'startspeaking' },
{ role: 'stopspeaking' }
]
}
] : [
{ role: 'delete' },
{ type: 'separator' },
{ role: 'selectAll' }
])
]
},
// { role: 'viewMenu' }
{
label: 'View',
submenu: [
{ role: 'reload' },
{ role: 'forcereload' },
{ role: 'toggledevtools' },
{ type: 'separator' },
{ role: 'resetzoom' },
{ role: 'zoomin' },
{ role: 'zoomout' },
{ type: 'separator' },
{ role: 'togglefullscreen' }
]
},
// { role: 'windowMenu' }
{
label: 'Window',
submenu: [
{ role: 'minimize' },
{ role: 'zoom' },
...(isMac ? [
{ type: 'separator' },
{ role: 'front' },
{ type: 'separator' },
{ role: 'window' }
] : [
{ role: 'close' }
])
]
},
{
role: 'help',
submenu: [
{
label: 'Learn More',
click () { require('electron').shell.openExternalSync('https://electronjs.org') }
}
]
}
]
const menu = Menu.buildFromTemplate(template)
Menu.setApplicationMenu(menu)

Related

Electron app reactivate window using Tray Icon

when we Minimize the application, how reactive the window by using Tray menu
const tray = new Tray(path.join(__dirname, '/assets/icons/commusoft-squarelogo.png'))
const contextMenu = Menu.buildFromTemplate([
{ label: 'Active', type:'normal',role: 'front', click:try_click() },
{ label: 'Preferences', type: 'normal',click: try_click()},
{ label: 'Reload', type: 'normal', role: 'reload'},
{ label: 'Reload new', type: 'normal', role: 'reload'},
{ label: 'Quit', type: 'normal', role: 'quit' }
])
tray.setToolTip('This is my application.')
tray.setContextMenu(contextMenu)
Thanks in advance!!!
now finally figure out the answer
const contextMenu = Menu.buildFromTemplate([
{ label: 'Active', type:'normal',role: 'front', click:function(){
win.show()
}
},
{ label: 'Preferences', type: 'normal',click: try_click()},
{ label: 'Reload', type: 'normal', role: 'reload'},
{ label: 'Reload new', type: 'normal', role: 'reload'},
{ label: 'Quit', type: 'normal', role: 'quit' }
])

How can i add list items and heading together, in the below code i don't see li at all

{{ apos.area(data.page, 'body', { widgets: { 'apostrophe-images': { size: 'full' }, 'apostrophe-rich-text': { toolbar: [ 'Styles', 'Bold', 'Italic', 'Link', 'Unlink','Table' ], styles: [ { name: 'Heading', element: 'h3' }, { name: 'Paragraph', element: 'p' }, { name: 'Listitems', element: 'li' } ] } } }) }}
To add lists to a rich text widget you want to add 'NumberedList' or 'BulletedList' to the toolbar array in your configuration.
Your code would look like
{{ apos.area(data.page, 'body', {
widgets: {
'apostrophe-images': { size: 'full' },
'apostrophe-rich-text': {
toolbar: [ 'Styles', 'Bold', 'Italic', 'Link', 'Unlink', 'Table', 'NumberedList', 'BulletedList' ],
styles: [
{ name: 'Heading', element: 'h3' },
{ name: 'Paragraph', element: 'p' }
]
}
}
}) }}

Bind data to grid after page load MVC

I have problem here.With kendo grid i'm loading data from some action in controller.But in the last column i have link which should fire another action in same controller.When i delete this piece of code
type: "json",
transport: {
read: {
url: "#Html.Raw(Url.Action("ListFinances", "Jobs"))",
type: "POST",
dataType: "json",
data: additionalData
},
},
schema: {
data: "Data",
total: "Total",
errors: "Errors"
},
last column is working perfect,bit when is present this piece of code, last column is not working>please here some help, i;m new to mvc.Below is the code:
$("#jobs-grid").kendoGrid({
dataSource: {
data: #Html.Raw(JsonConvert.SerializeObject(Model.FinishedJobs)),
schema: {
model: {
fields: {
JobNumber: { type: "string" },
CustomerId: { type: "number" },
JobCount: { type: "number" },
JobYear: { type: "number" },
Status: { type: "number" },
Position: { type: "number" },
Finished: { type: "boolean" },
HasInvoice: { type: "boolean" },
}
}
},
type: "json",
transport: {
read: {
url: "#Html.Raw(Url.Action("ListFinances", "Jobs"))",
type: "POST",
dataType: "json",
data: additionalData
},
},
schema: {
data: "Data",
total: "Total",
errors: "Errors"
},
error: function(e) {
display_kendoui_grid_error(e);
// Cancel the changes
this.cancelChanges();
},
pageSize: 20,
serverPaging: true,
serverFiltering: true,
serverSorting: true
},
//dataBound: onDataBound,
columns: [
#*{
field: "Status",
title: "Status",
template: '#= Status #'
},*#
{
field: "JobNumber",
title: "jobNumber",
template: '#= JobNumber #'
},
{
field: "CustomerId",
title: "Customer",
template: '#= Customer.Name #'
},
{
field: "Id",
title: "Id"
},
#*{
field: "ShortDesc",
title: "ShortDesc"
},*#
{
field: "DateCompletition",
title: "DateCompletition"
},
{
field: "Id",
title: "#T("Common.Edit")",
width: 130,
template: 'Edit'
}
],
pageable: {
refresh: true,
pageSizes: [5, 10, 20, 50]
},
editable: {
confirmation: false,
mode: "inline"
},
scrollable: false,
// sortable: true,
// navigatable: true,
// filterable: true,
// scrollable: true,
selectable: true
});
});
</script>
It seems you want to add a command to the grid, The way to add a command as described here is as follows
var grid = $("#jobs-grid").kendoGrid({
dataSource: {
pageSize: 20,
data: #Html.Raw(JsonConvert.SerializeObject(Model.FinishedJobs)),
},
pageable: true,
height: 550,
columns: [
{ field: "JobNumber", title: "JobNumber", width: "140px" },
{ field: "CustomerId", title: "Customer", width: "140px" },
{ field: "Id", title:"Id" },
{ field: "DateCompletition", title:"DateCompletition" },
{ command: { text: "Edit",
click: function(e){
// here you can add your code
}},
title: " ",
width: "180px" }]
}).data("kendoGrid");
You might have a look on the documentation of the kendo grid here
Hope this will help you

kendo ui Grid "Popup mode" ,Edit And Delete Button, Not firing the Controller Action

This is My view with kendo ui grid, It's Read function firing just fine, but the problem just begins when I want to update,
The update Function in my controller Not even Firing,
<script>
$(document).ready(function () {
var dataSource = {
transport: {
type: "json",
read: {
url: "#Html.Raw(Url.Action("CommentList", "Comment"))",
type: "POST",
dataType: "json"
},
update: {
url: "#Html.Raw(Url.Action("CommentUpdate", "Comment"))",
type: "POST",
dataType: "json"
},
destroy: {
url: "#Html.Raw(Url.Action("CommentDelete", "Comment"))",
type: "POST",
dataType: "json"
}
},
schema: {
data: "Data",
total: "Total",
errors: "Errors",
model: {
id: "Id",
fields: {
Id: { type: "number" },
ProductName: { editable: false, type: "string"},
ProductPicture: { editable: false, type: "string"},
Text: { editable: false, type: "string"},
AdminConfirm: { editable: true, type: "boolean", validation: { required: true } }
}
}
},
requestEnd: function (e) {
if (e.type === "create" || e.type === "update") {
this.read();
}
},
error: function (e) {
alert("something wrong!");
// Cancel the changes
this.cancelChanges();
},
pageSize: 15,
serverPaging: true,
serverFiltering: true,
serverSorting: true
};
$("#grid").kendoGrid({
dataSource: dataSource,
pageable: {
refresh: true,
pageSizes: [10, 15, 20, 30, 50]
},
height: 550,
columns: [
{
field: "ProductName",
title: "product name",
width: "90px"
},
{
field: "ProductPicture",
title: "picture",
width: "100px",
},
{
field: "Text",
title: "comment",
width: "180px"
},
{
field: "AdminConfirm",
title: "adminconfirm",
width: "70px",
},
{
command: [
{
name: "edit" , text: { // sets the text of the "Edit", "Update" and "Cancel" buttons
edit: "edit",
update: "update",
cancel: "cancel"
}
}
],
title: " ", width: "250px"
}
],
editable : {
mode : "popup",
window : {
title: "confirmation form"
}}
});
});
</script>
</div>
This is My first line of update Function
[HttpPost]
public ActionResult CommentUpdate(DataSourceRequest request, CommentViewModel comment)
Anybody Know Why?
Thanx in Advance

Kendo UI Grid update event is not firing

I have Kendo UI inline Grid. It read and populate the grid properly. but when i press edit and changes in any column and press update then update event is not firing.
and it also not calling controller method.
Hope someone can help me point out what I am doing wrong here.
following is my grid binding.
dataSource = new kendo.data.DataSource({
transport: {
read: function (options) {
$.ajax({
type: 'POST',
url: "./GetIngredients",
dataType: "json",
success: function (result) {
options.success(result);
}
});
},
update: function (options) {
$.ajax({
type: 'POST',
url: "./UpdateData",
dataType: "json",
contentType: "application/json; charset=utf-8"
});
},
parameterMap: function (options, operation) {
alert('1');
if (operation !== "read" && options.models) {
alert('2');
return { models: kendo.stringify(options.models) };
}
}
},
batch: true,
pageSize: 20,
schema: {
model: {
id: "Id",
fields: {
Id: { editable: false, nullable: true },
Division: { type: "string", editable: true, nullable: false },
GroupName: { type: "string", validation: { required: true } },
CategoryName: { type: "string" },
TypeName: { type: "string" },
ItemName: { type: "string" }
}
}
}
});
var grid = $("#grid").kendoGrid(
{
dataSource: dataSource,
height: 430,
scrollable: true,
pageable: true,
navigatable: true,
columns: [
{ field: "Division", title: "Division", width: "80px" },
{ field: "GroupName", title: "Group Name", width: "70px" },
{ field: "CategoryName", title: "Category Name", width: "110px" },
{ field: "TypeName", title: "Type Name", width: "100px" },
{ field: "ItemName", width: "140px" },
{ command: ["edit", "destroy"], title: " ", width: "170px" }],
editable: "inline"
}).data("kendoGrid");
following is the method in Homecontroller.
[HttpPost]
public JsonResult GetIngredients()
{
IngredientData ingredientData = new IngredientData();
ingredientData.Id = 1;
ingredientData.DivisionId = 1;
ingredientData.Division = "Division Abc";
ingredientData.GroupId = 2;
ingredientData.GroupName = "Group -A";
ingredientData.CategoryId = 3;
ingredientData.CategoryName = "Category -D";
ingredientData.FoodTypeId = 4;
ingredientData.TypeName = "Type One";
ingredientData.ItemId = 5;
ingredientData.ItemName = "Item One";
return Json( ingredientData , JsonRequestBehavior.AllowGet);
}
[HttpPost]
public void UpdateData()
{
// logic for update data in database.
}
Did you realize that you have batch set to true? When in batch mode, you have to invoke sync on dataSource or saveChanges in Grid definition.
Try adding a toolbar command for invoking saveChanges as follow:
var grid = $("#grid").kendoGrid({
dataSource: dataSource,
height: 430,
scrollable: true,
pageable: true,
navigatable: true,
toolbar: [ "save" ],
columns: [
{ field: "Division", title: "Division", width: "80px" },
{ field: "GroupName", title: "Group Name", width: "70px" },
{ field: "CategoryName", title: "Category Name", width: "110px" },
{ field: "TypeName", title: "Type Name", width: "100px" },
{ field: "ItemName", width: "140px" },
{ command: ["edit", "destroy"], title: " ", width: "170px" }],
editable: "inline"
}).data("kendoGrid");
or simply remove batch mode.
I have faced same issue. But I have solved using this.
To fire create/delete/update we need to specify schema in dataSource( in schema we should mention atleast what is id field).
schema: {
model: {
id: "StudentID"
}
}
Code:
var dataSource = new kendo.data.DataSource({
transport: {
read: function (options) {
alert("read");
},
create: function (options) {
alert("create");
},
update: function (options) {
alert("update"); },
destroy: function (options) {
alert("destroy"); }
},
schema: {
model: {
id: "StudentID"
}
}

Resources