Mix clickable row and unclickable row on slickgrid
For my columns definition.
var columns = [
{id: "label", name: "point", formatter:this.clickableFormatter,field: "point",width: 150},
then I add clickhander for it.
chart.addClickHandler(){
}
Also I use clickableFormatter
for this.
clickableFormatter(row,cell,value,columnDef,dataContext){
return "<span style='cursor:pointer;'>" + value + "</span>";
}
From these code. my table rows are clickable and I can show the user where is clickable by changing pointer.
However now I want to make one row unclickable.
(for example total
row)
Is it possible to prevent click event for one low??
And is it possible to use another formatter
for one row?
I gave the data from for loop
and add total
seperately.
for (var k = 0 ; k < data.length ;k++){
var temp = new Array();
temp['id'] = data[k]['id'];
temp['point'] = data[k]['point'];
ret.push(temp);
}
ret.push({
'id' : "total",
"point" : pointTotal,
});
javascript jquery slickgrid
add a comment |
For my columns definition.
var columns = [
{id: "label", name: "point", formatter:this.clickableFormatter,field: "point",width: 150},
then I add clickhander for it.
chart.addClickHandler(){
}
Also I use clickableFormatter
for this.
clickableFormatter(row,cell,value,columnDef,dataContext){
return "<span style='cursor:pointer;'>" + value + "</span>";
}
From these code. my table rows are clickable and I can show the user where is clickable by changing pointer.
However now I want to make one row unclickable.
(for example total
row)
Is it possible to prevent click event for one low??
And is it possible to use another formatter
for one row?
I gave the data from for loop
and add total
seperately.
for (var k = 0 ; k < data.length ;k++){
var temp = new Array();
temp['id'] = data[k]['id'];
temp['point'] = data[k]['point'];
ret.push(temp);
}
ret.push({
'id' : "total",
"point" : pointTotal,
});
javascript jquery slickgrid
add a comment |
For my columns definition.
var columns = [
{id: "label", name: "point", formatter:this.clickableFormatter,field: "point",width: 150},
then I add clickhander for it.
chart.addClickHandler(){
}
Also I use clickableFormatter
for this.
clickableFormatter(row,cell,value,columnDef,dataContext){
return "<span style='cursor:pointer;'>" + value + "</span>";
}
From these code. my table rows are clickable and I can show the user where is clickable by changing pointer.
However now I want to make one row unclickable.
(for example total
row)
Is it possible to prevent click event for one low??
And is it possible to use another formatter
for one row?
I gave the data from for loop
and add total
seperately.
for (var k = 0 ; k < data.length ;k++){
var temp = new Array();
temp['id'] = data[k]['id'];
temp['point'] = data[k]['point'];
ret.push(temp);
}
ret.push({
'id' : "total",
"point" : pointTotal,
});
javascript jquery slickgrid
For my columns definition.
var columns = [
{id: "label", name: "point", formatter:this.clickableFormatter,field: "point",width: 150},
then I add clickhander for it.
chart.addClickHandler(){
}
Also I use clickableFormatter
for this.
clickableFormatter(row,cell,value,columnDef,dataContext){
return "<span style='cursor:pointer;'>" + value + "</span>";
}
From these code. my table rows are clickable and I can show the user where is clickable by changing pointer.
However now I want to make one row unclickable.
(for example total
row)
Is it possible to prevent click event for one low??
And is it possible to use another formatter
for one row?
I gave the data from for loop
and add total
seperately.
for (var k = 0 ; k < data.length ;k++){
var temp = new Array();
temp['id'] = data[k]['id'];
temp['point'] = data[k]['point'];
ret.push(temp);
}
ret.push({
'id' : "total",
"point" : pointTotal,
});
javascript jquery slickgrid
javascript jquery slickgrid
edited Nov 25 '18 at 13:44
whitebear
asked Nov 25 '18 at 13:21
whitebearwhitebear
2,860124492
2,860124492
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
In your formatter, you have access to the value of the cell, so if value==='total'
, just return an empty string.
Also FYI, I don't think you need the for
loop in your code (you could just leave it out entirely), unless you're using it to calculate the total, but you don't seem to be doing that.
If you think that you need it for creating the array objects, you're misunderstanding arrays in javascript, what you're actually setting is object properties, and it would be usual to initialise with var temp = { };
rather than as Array.
It may not make sense at first, but everything in javascript is an object, including arrays and functions. So you can add object properties to anything.
somevar[numericVal] = x; // set array element, somevar must be type Array
somevar['stringVal'] = x; // set object property 'stringVal'
somevar.stringVal = x; // identical to above line, different way of specifying
As you told, I can use value in formatter. It solves the problem. and for loop, I was stupid!! thank you very much!! However I am not sure why var temp ={} is better than Array(); it is because of memory usage??
– whitebear
Dec 2 '18 at 3:23
Sorry, I can't find a link that explains it well. But in that loop you are using object properties. var temp = {}; declares an object, which you can set properties on. var temp = ; or var temp = Array; (the same) declare an array, which is also an object, so you can set object properties on them also. You just never use their actual array functionality.
– Ben McIntyre
Dec 2 '18 at 18:54
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53467896%2fmix-clickable-row-and-unclickable-row-on-slickgrid%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
In your formatter, you have access to the value of the cell, so if value==='total'
, just return an empty string.
Also FYI, I don't think you need the for
loop in your code (you could just leave it out entirely), unless you're using it to calculate the total, but you don't seem to be doing that.
If you think that you need it for creating the array objects, you're misunderstanding arrays in javascript, what you're actually setting is object properties, and it would be usual to initialise with var temp = { };
rather than as Array.
It may not make sense at first, but everything in javascript is an object, including arrays and functions. So you can add object properties to anything.
somevar[numericVal] = x; // set array element, somevar must be type Array
somevar['stringVal'] = x; // set object property 'stringVal'
somevar.stringVal = x; // identical to above line, different way of specifying
As you told, I can use value in formatter. It solves the problem. and for loop, I was stupid!! thank you very much!! However I am not sure why var temp ={} is better than Array(); it is because of memory usage??
– whitebear
Dec 2 '18 at 3:23
Sorry, I can't find a link that explains it well. But in that loop you are using object properties. var temp = {}; declares an object, which you can set properties on. var temp = ; or var temp = Array; (the same) declare an array, which is also an object, so you can set object properties on them also. You just never use their actual array functionality.
– Ben McIntyre
Dec 2 '18 at 18:54
add a comment |
In your formatter, you have access to the value of the cell, so if value==='total'
, just return an empty string.
Also FYI, I don't think you need the for
loop in your code (you could just leave it out entirely), unless you're using it to calculate the total, but you don't seem to be doing that.
If you think that you need it for creating the array objects, you're misunderstanding arrays in javascript, what you're actually setting is object properties, and it would be usual to initialise with var temp = { };
rather than as Array.
It may not make sense at first, but everything in javascript is an object, including arrays and functions. So you can add object properties to anything.
somevar[numericVal] = x; // set array element, somevar must be type Array
somevar['stringVal'] = x; // set object property 'stringVal'
somevar.stringVal = x; // identical to above line, different way of specifying
As you told, I can use value in formatter. It solves the problem. and for loop, I was stupid!! thank you very much!! However I am not sure why var temp ={} is better than Array(); it is because of memory usage??
– whitebear
Dec 2 '18 at 3:23
Sorry, I can't find a link that explains it well. But in that loop you are using object properties. var temp = {}; declares an object, which you can set properties on. var temp = ; or var temp = Array; (the same) declare an array, which is also an object, so you can set object properties on them also. You just never use their actual array functionality.
– Ben McIntyre
Dec 2 '18 at 18:54
add a comment |
In your formatter, you have access to the value of the cell, so if value==='total'
, just return an empty string.
Also FYI, I don't think you need the for
loop in your code (you could just leave it out entirely), unless you're using it to calculate the total, but you don't seem to be doing that.
If you think that you need it for creating the array objects, you're misunderstanding arrays in javascript, what you're actually setting is object properties, and it would be usual to initialise with var temp = { };
rather than as Array.
It may not make sense at first, but everything in javascript is an object, including arrays and functions. So you can add object properties to anything.
somevar[numericVal] = x; // set array element, somevar must be type Array
somevar['stringVal'] = x; // set object property 'stringVal'
somevar.stringVal = x; // identical to above line, different way of specifying
In your formatter, you have access to the value of the cell, so if value==='total'
, just return an empty string.
Also FYI, I don't think you need the for
loop in your code (you could just leave it out entirely), unless you're using it to calculate the total, but you don't seem to be doing that.
If you think that you need it for creating the array objects, you're misunderstanding arrays in javascript, what you're actually setting is object properties, and it would be usual to initialise with var temp = { };
rather than as Array.
It may not make sense at first, but everything in javascript is an object, including arrays and functions. So you can add object properties to anything.
somevar[numericVal] = x; // set array element, somevar must be type Array
somevar['stringVal'] = x; // set object property 'stringVal'
somevar.stringVal = x; // identical to above line, different way of specifying
edited Nov 27 '18 at 23:05
answered Nov 27 '18 at 22:46
Ben McIntyreBen McIntyre
1,3751020
1,3751020
As you told, I can use value in formatter. It solves the problem. and for loop, I was stupid!! thank you very much!! However I am not sure why var temp ={} is better than Array(); it is because of memory usage??
– whitebear
Dec 2 '18 at 3:23
Sorry, I can't find a link that explains it well. But in that loop you are using object properties. var temp = {}; declares an object, which you can set properties on. var temp = ; or var temp = Array; (the same) declare an array, which is also an object, so you can set object properties on them also. You just never use their actual array functionality.
– Ben McIntyre
Dec 2 '18 at 18:54
add a comment |
As you told, I can use value in formatter. It solves the problem. and for loop, I was stupid!! thank you very much!! However I am not sure why var temp ={} is better than Array(); it is because of memory usage??
– whitebear
Dec 2 '18 at 3:23
Sorry, I can't find a link that explains it well. But in that loop you are using object properties. var temp = {}; declares an object, which you can set properties on. var temp = ; or var temp = Array; (the same) declare an array, which is also an object, so you can set object properties on them also. You just never use their actual array functionality.
– Ben McIntyre
Dec 2 '18 at 18:54
As you told, I can use value in formatter. It solves the problem. and for loop, I was stupid!! thank you very much!! However I am not sure why var temp ={} is better than Array(); it is because of memory usage??
– whitebear
Dec 2 '18 at 3:23
As you told, I can use value in formatter. It solves the problem. and for loop, I was stupid!! thank you very much!! However I am not sure why var temp ={} is better than Array(); it is because of memory usage??
– whitebear
Dec 2 '18 at 3:23
Sorry, I can't find a link that explains it well. But in that loop you are using object properties. var temp = {}; declares an object, which you can set properties on. var temp = ; or var temp = Array; (the same) declare an array, which is also an object, so you can set object properties on them also. You just never use their actual array functionality.
– Ben McIntyre
Dec 2 '18 at 18:54
Sorry, I can't find a link that explains it well. But in that loop you are using object properties. var temp = {}; declares an object, which you can set properties on. var temp = ; or var temp = Array; (the same) declare an array, which is also an object, so you can set object properties on them also. You just never use their actual array functionality.
– Ben McIntyre
Dec 2 '18 at 18:54
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53467896%2fmix-clickable-row-and-unclickable-row-on-slickgrid%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown