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

String Manipulation

1 Answer 923 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 06 Feb 2019, 05:58 PM

I have a Grid that I need to create a URL where part of the URL is part of the Bound Data from another field.  

 

So for example I have the Bound column \\#= MAPNAME \\# that will have the data   A30-32-A1 and I need to get the first 3 characters A30 

In my VB head I just want to use a LEFT string command. Is there a way to do a manipulation to get this to be part of the URL I am trying to concatenate? 

Here is  snippet of the line I am trying to edit and below that the Grid call (all of the code)  I don't really want to have to edit the controller or model... any suggestions?

columns.Bound(m => m.GRIDPRTID)
                  .ClientTemplate("<a href='" + Url.Content("http://gis.xxxxxx.com/GISGateway/GridPrints/IN NEED THE A30 HERE/A30-32-A1.pdf") + "' target='_blank'>\\#= MAPNAME \\#.pdf</a>");

 

@(Html.Kendo().Grid(new List<GRIDPRINTS>())  //<GISPortal.GRIDPRINTS>()
            .Name("grid_#=WOID#") // template expression, to be evaluated in the master context
 
            .Columns(columns =>
            {
                columns.Bound(o => o.GRIDPRTID).Width(110).Title("GridID");
                columns.Bound(o => o.MAPNAME).Width(110).Title("Name");
                columns.Bound(o => o.GRIDID).Width(110).Title("GridID");
                columns.Bound(o => o.SCALE).Width(110).Title("Scale");
                columns.Bound(o => o.PAGENUMBER).Title("PgNum");   
                columns.Bound(o => o.STATUS).Width(200).Title("Status");
                columns.Bound(o => o.ERRORS).Width(300).Title("Errors?");
 
 
                columns.Bound(m => m.GRIDPRTID)
                  .ClientTemplate("<a href='" + Url.Content("file://macfap01/GIS/GridPrints/A21/\\#= MAPNAME \\#.pdf") + "' target='_blank'>\\#= MAPNAME \\#.pdf</a>");
 
 
 
 
 
                columns.Bound(m => m.MAPNAME).Hidden()
                  .ClientTemplate("<input type='hidden' "
                  + "name='MAPNAME[\\#= GRIDPRTID \\#]' "    //                  + "name='THEMAPNAME[\\#= GRIDPRTID \\#].MAPNAME' "
                  + "value='\\#= MAPNAME \\#' />");
 
                columns.Bound(m => m.PAGENUMBER).Hidden()
                  .ClientTemplate("<input type='hidden' "
                  + "name='PAGENUMBER[\\#= GRIDPRTID \\#]' "    //   + "name='THEPAGENUMBER[\\#= GRIDPRTID \\#].PAGENUMBER' "
                  + "value='\\#= PAGENUMBER \\#' />");
 
                columns.Bound(m => m.SCALE).Hidden()
                  .ClientTemplate("<input type='hidden' "
                  + "name='SCALE[\\#= GRIDPRTID \\#]' "   //+ "name='THESCALE[#=gridIndex(data)#].SCALE' "
                  + "value='\\#= SCALE \\#' />");
 
                columns.Bound(m => m.WOID).Hidden()
                  .ClientTemplate("<input type='hidden' "
                  + "name='WOID[\\#= GRIDPRTID \\#]' "   //+ "name='THESCALE[#=gridIndex(data)#].SCALE' "
                  + "value='\\#= WOID \\#' />");
 
                columns.Bound(o => o.MAPNAME).Width(110).Title("ReSend")
                     .ClientTemplate("<input type='checkbox' "
                     + "name='checked[\\#= GRIDPRTID \\#]' "    //                     + "name='CHECKED\\#= WOID \\#.MAPNAME' "
                     + "value='true' "
                     + "#if (WOID) { #checked='checked'# } #/>"
                     + "<input type='hidden' value='false' "
                     + "name='checked[\\#= GRIDPRTID \\#]' />");   //                     + "name='themapname\\#= WOID \\#.MAPNAME' />");
 
            })
            .DataSource(dataSource => dataSource
                .Ajax()
                .PageSize(10)
                .Read(read => read.Action("GRIDPRINTS_Read", "GridPrint", new { woid = "#=WOID#" }))
                .ServerOperation(false)
            )
            .Pageable()
            .Sortable()
            .ToClientTemplate()
    )

1 Answer, 1 is accepted

Sort by
0
Jason
Top achievements
Rank 1
answered on 06 Feb 2019, 07:55 PM

Figured it out

 

I created a Javascript function outside the GRID 

    <script type="text/javascript">
        function replaceString(value) {
            return value.substring(0, 3);
        }
    </script>

Then my code

 

            columns.Bound(m => m.GRIDPRTID)
                              .ClientTemplate("<a href='" + Url.Content("http://gis.xxxx.com/GISGateway/GridPrints/\\#= kendo.toString(replaceString(MAPNAME)) \\#/\\#= MAPNAME \\#.pdf") + "' target='_blank'>\\#= MAPNAME \\#</a>");

 

 

I'm now trying to add the column name in the template  

Tags
Grid
Asked by
Jason
Top achievements
Rank 1
Answers by
Jason
Top achievements
Rank 1
Share this question
or