Hide Column In OOTB SharePoint Gannt View And Datasheet View

Problem

In one of the my project, I have to hide the columns in SharePoint OOTB Datasheet view and Gannt view, using JavaScript/jQuery.
 
Solution
 
After search many times, on the above problem, I have found that SharePoint OOTB Datasheet view and Gannt View are used JSGrid to quickly edit the list items in SharePoint.
 
To hide the columns in both the views, we need to first identify View ID for Gannt View or DataSheet View. 
 
The guid is of the Gannt View. You can snoop it. e.g. from page source. Search for g_ViewIfToViewCounterMap. 

There will be only one such place, in case you have one Gannt View or DataSheet View on the page. The GUID to the right is exactly, what you need.
 
After getting GUID for Gannt or Datasheet view, we need to write the code, given below, in document.ready or window.load function to hide the columns in Gannt view.
 
Code for DataSheet View 
  1. $(document).ready(function() {  
  2.     var viewId = "{E41180E8-CCE3-424A-A525-9A0A6F19DF13}"// Put Datasheet view GUID  
  3.     var jsGridContainer = $get("spgridcontainer_" + g_SPGridInitInfo[viewId].jsInitObj.qualifier); // It will return jsgrid container  
  4.     var jsGrid = jsGridContainer.jsgrid; // Find jsgrid from jsgrid container   
  5.     var columns = jsGrid.GetColumns(); // All columns in Datasheet View  
  6.     for (var i in columns) {  
  7.         columns[i].isSortable = false// If we want to disable sorting in all fields  
  8.         columns[i].isAutoFilterable = false;  
  9.     }  
  10.     jsGrid.UpdateColumns(new SP.JsGrid.ColumnInfoCollection(columns));  
  11.     // Hide master lookup column  
  12.     jsGrid.HideColumn("Column Name");  
  13. });   
Code for Gannt View 
  1. $(document).ready(function()  
  2. {  
  3. $("div [id$='_ListViewWebPartJSGrid']")[0].jsgrid.HideColumn("Column Name");   
  4. });