This is a migrated thread and some comments may be shown as answers.

[Solved] Hide "Add new record" button

4 Answers 177 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Howard
Top achievements
Rank 1
Howard asked on 28 May 2012, 05:40 AM
Hi Telerik Team,

I need to hide the "add new record" button when a condition is fulfilled.  I'm trying to accomplish this using jquery on onDataBound event as this is the last event fired before the grid is rendered as described in (http://demos.telerik.com/aspnet-mvc/grid/clientsideevents).

This are my functions:
var totalPercentage = 0;
  
    function onSaveJobList(e){
        //clear the total Percentage for add/edit
        totalPercentage = 0;
    }
  
    function onRowDataBoundJobList(e){        
        totalPercentage = totalPercentage + e.dataItem["PERCENTAGE"];
    }
  
    function onDataBoundJobList(e){
        debugger
        $("#TOTAL_SPLITED").attr('value', ($("#TO_INVOICE_AMOUNT").val() * totalPercentage/100).toFixed(2));
  
        if(totalPercentage == 100){
            //$(".t-toolbar", $(this)).css("visibility:hidden");
            $(".t-toolbar", $(this)).css("display:none");
        }
        else{
            $(".t-toolbar", $(this)).css("visibility:visible");
        }
    }


Please let me know where am I doing wrong as it is not hiding the button/updating the css.

Thank you

4 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 28 May 2012, 12:02 PM
Hi Niroj,

The css() jQuery method should have two arguments in your case. Please consult the jQuery documentation.

I recommend you to hide the button with a visibility:hidden style, instead of hiding the whole toolbar. The latter will cause either content flicker, or whitespace inside the Grid component.

All the best,
Dimo
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
0
Samantha
Top achievements
Rank 1
answered on 24 Jul 2012, 07:26 AM
@Dimo, can you provide a sample? Im having the same issue as the thread starter

thanks
0
Sarada
Top achievements
Rank 1
answered on 02 Aug 2012, 08:40 AM
Hi,

I am doing that in the following way.

// After 10 records, hide the Add button
    if (e.target.id == "grdSample") {
        if (($(this).parent().parent().find('tr').length - 1) >= 10) {
            $(this).find('.t-grid-add').hide();
        }
    }
0
Mahesh
Top achievements
Rank 1
answered on 14 Aug 2012, 10:40 AM
Hi Dimo,

Is it possible to remove 'Add New Record' (command.Template) from the toolbar of the telerik mvc grid before loading the grid..........
Please Help me....


Thanks & Regards,
Mahesh
Tags
Grid
Asked by
Howard
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Samantha
Top achievements
Rank 1
Sarada
Top achievements
Rank 1
Mahesh
Top achievements
Rank 1
Share this question
or