Skip to main content
grammar
Source Link
Dylan Cristy
  • 12.8k
  • 3
  • 32
  • 72

I need to make bythe action of clicking on the title of a list item, to open the edit form, and not the view form. To do this I chose theto use CSR,.

I have the following code:

(function () {
    var statusFieldCtx = {};
  
    statusFieldCtx.Templates = {};
    statusFieldCtx.Templates.Fields = {
        "Title": {"View": DataFieldViewTemplate},
        
    };

    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(statusFieldCtx);
})();

function DataFieldViewTemplate(ctx) {       
    var data = ctx.CurrentItem.Title;
    console.log(data);      
}

But I see nothing in the browser console. If I change the code, this works, but the title column does not exist. My

Here is my edited code:

(function () {
    var statusFieldCtx = {};
  
    statusFieldCtx.Templates = {};
    statusFieldCtx.Templates.Fields = {
        "dt_x0020_proximo_x0020_contato": {"View": DataFieldViewTemplate},
        
    };

    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(statusFieldCtx);
})();

function DataFieldViewTemplate(ctx) {       
    var data = ctx;
    console.log(data);      
}

My questions are: Is there any error in my code? I canCan I do what I want in a different way?

I need to make by clicking on the title of a list item, to open the edit form and not the view form. To do this I chose the CSR, I have the code:

(function () {
    var statusFieldCtx = {};
  
    statusFieldCtx.Templates = {};
    statusFieldCtx.Templates.Fields = {
        "Title": {"View": DataFieldViewTemplate},
        
    };

    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(statusFieldCtx);
})();

function DataFieldViewTemplate(ctx) {       
    var data = ctx.CurrentItem.Title;
    console.log(data);      
}

But I see nothing in the browser console. If I change the code this works, but the title column not exist. My edited code:

(function () {
    var statusFieldCtx = {};
  
    statusFieldCtx.Templates = {};
    statusFieldCtx.Templates.Fields = {
        "dt_x0020_proximo_x0020_contato": {"View": DataFieldViewTemplate},
        
    };

    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(statusFieldCtx);
})();

function DataFieldViewTemplate(ctx) {       
    var data = ctx;
    console.log(data);      
}

My questions are: Is there any error in my code? I can do what I want in a different way?

I need to make the action of clicking on the title of a list item open the edit form, and not the view form. To do this I chose to use CSR.

I have the following code:

(function () {
    var statusFieldCtx = {};
  
    statusFieldCtx.Templates = {};
    statusFieldCtx.Templates.Fields = {
        "Title": {"View": DataFieldViewTemplate},
        
    };

    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(statusFieldCtx);
})();

function DataFieldViewTemplate(ctx) {       
    var data = ctx.CurrentItem.Title;
    console.log(data);      
}

But I see nothing in the browser console. If I change the code, this works, but the title column does not exist.

Here is my edited code:

(function () {
    var statusFieldCtx = {};
  
    statusFieldCtx.Templates = {};
    statusFieldCtx.Templates.Fields = {
        "dt_x0020_proximo_x0020_contato": {"View": DataFieldViewTemplate},
        
    };

    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(statusFieldCtx);
})();

function DataFieldViewTemplate(ctx) {       
    var data = ctx;
    console.log(data);      
}

My questions are: Is there any error in my code? Can I do what I want in a different way?

Tweeted twitter.com/#!/StackSharePoint/status/444971002066661376
Source Link
Diego Hillesheim
  • 1.2k
  • 3
  • 18
  • 26

ctx in CSR not return the title

I need to make by clicking on the title of a list item, to open the edit form and not the view form. To do this I chose the CSR, I have the code:

(function () {
    var statusFieldCtx = {};
  
    statusFieldCtx.Templates = {};
    statusFieldCtx.Templates.Fields = {
        "Title": {"View": DataFieldViewTemplate},
        
    };

    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(statusFieldCtx);
})();

function DataFieldViewTemplate(ctx) {       
    var data = ctx.CurrentItem.Title;
    console.log(data);      
}

But I see nothing in the browser console. If I change the code this works, but the title column not exist. My edited code:

(function () {
    var statusFieldCtx = {};
  
    statusFieldCtx.Templates = {};
    statusFieldCtx.Templates.Fields = {
        "dt_x0020_proximo_x0020_contato": {"View": DataFieldViewTemplate},
        
    };

    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(statusFieldCtx);
})();

function DataFieldViewTemplate(ctx) {       
    var data = ctx;
    console.log(data);      
}

My questions are: Is there any error in my code? I can do what I want in a different way?